Writing a Text in StreamWriter such that alignment should be proper for different languages ( like English, Chinise, German...etc).
-
Hi All, I am writing text into StreamWriter by sw.Write("Text coming from Labels : so can be in english or chinese or any other languages") method. After writing first text, I am adding tabs and then adding second text. Now adding a new line and adding first text + tabs + second text. It looks like this: Model :\t \t \t \t \t XXXX Version :\t \t \t \t YYYY Note : I am not able to put white spaces here so just putted \t. Assume that the first X and first Y starting position is equal. Alignment is coming properly for English. But if the input texts are in Chinese then it comes like this : Model :\t \t \t \t \t XXXX Version :\t \t \t \t YYYY Here YYYY is not coming just below XXXX such that the start position of first X and first Y should be same, This Tab spaces are the same for different languages. I want atleast alignment should be proper with every languages. Thanks in Advance.. Piyush Vaishnav
-
Hi All, I am writing text into StreamWriter by sw.Write("Text coming from Labels : so can be in english or chinese or any other languages") method. After writing first text, I am adding tabs and then adding second text. Now adding a new line and adding first text + tabs + second text. It looks like this: Model :\t \t \t \t \t XXXX Version :\t \t \t \t YYYY Note : I am not able to put white spaces here so just putted \t. Assume that the first X and first Y starting position is equal. Alignment is coming properly for English. But if the input texts are in Chinese then it comes like this : Model :\t \t \t \t \t XXXX Version :\t \t \t \t YYYY Here YYYY is not coming just below XXXX such that the start position of first X and first Y should be same, This Tab spaces are the same for different languages. I want atleast alignment should be proper with every languages. Thanks in Advance.. Piyush Vaishnav
a text file contains text, not formatting. the only way to give it some columnar layout without using a command language, is by inserting the right number of spaces and using a non-proportional (i.e. monospaced) font, such as Courier New. I expect there isn't a non-proportional font for Chinese. Using tabs to replace spaces could work also, there may be some issues. And it is a first step towards a command language. Real command languages would be HTML, RTF, PostScript, etc. In summary, there is no general solution IMO. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
Hi All, I am writing text into StreamWriter by sw.Write("Text coming from Labels : so can be in english or chinese or any other languages") method. After writing first text, I am adding tabs and then adding second text. Now adding a new line and adding first text + tabs + second text. It looks like this: Model :\t \t \t \t \t XXXX Version :\t \t \t \t YYYY Note : I am not able to put white spaces here so just putted \t. Assume that the first X and first Y starting position is equal. Alignment is coming properly for English. But if the input texts are in Chinese then it comes like this : Model :\t \t \t \t \t XXXX Version :\t \t \t \t YYYY Here YYYY is not coming just below XXXX such that the start position of first X and first Y should be same, This Tab spaces are the same for different languages. I want atleast alignment should be proper with every languages. Thanks in Advance.. Piyush Vaishnav
Much as Luc said, your choices are either to use delimiters (or markup), or to go to fixed-width columns. You can use
string.PadLeft
or.PadRight
to achieve columns, but you'll need to know the maximum length possible in each column (or truncate longer data). It's not good to try to store your formatting in with your data, I would recommend delimited text or finding a solution via XML and finally using something to generate your display (rather than relying intrinsically on the stored data). Cheers.My Latest: How quickly is the Government spending your money? Tech blog: They Call me Mister James
-
Much as Luc said, your choices are either to use delimiters (or markup), or to go to fixed-width columns. You can use
string.PadLeft
or.PadRight
to achieve columns, but you'll need to know the maximum length possible in each column (or truncate longer data). It's not good to try to store your formatting in with your data, I would recommend delimited text or finding a solution via XML and finally using something to generate your display (rather than relying intrinsically on the stored data). Cheers.My Latest: How quickly is the Government spending your money? Tech blog: They Call me Mister James
Hi, Now I used string.PadRight(40, ' ') for the first text and then after adding second text. It's working fine for english. But for Chinese still second text is not coming below the First Row's second text.
-
Hi, Now I used string.PadRight(40, ' ') for the first text and then after adding second text. It's working fine for english. But for Chinese still second text is not coming below the First Row's second text.
Are you adding the required line breaks? If you reveal a bit of your code it might help others solve the problem. As previously stated, you're going to have a hard time finding a balance of content and format. Once, there was this whole thing about HTML and CSS, and then, this other time, XML and XSL/T...
My Latest: How quickly is the Government spending your money? Tech blog: They Call me Mister James