D
Dancefire
Hi,
string.Format("{0,-20} : {1,-10}", a,b);
The above code will output string left aligned, 20 or 10 for string a
and b. It true for English, but not for any CJK language.
If a or b are CJK string, it will never aligned. The reason is that
for Chinese (or Japanese, Korean), each character will occupy 2
alphabeta space (not only 2 byte for MBCS in memory). For example:
"$BCfJ8(B" will have same visual length with "abcd", however,
string.Format() will treat "$BCfJ8(B" as 2 chars, and "abcd" as 4 chars, so
string.Format() will padding "$BCfJ8(B" for 18 space, and 16 space for
"abcd" if we aligned by 20. So if we see the result, the "$BCfJ8(B" will
longer than "abcd" since over padding.
This is the problem I am facing. Is it a bug in .Net framework? or is
there anything wrong with me, and I could overcome it be setting any
culture info?
Thanks.
string.Format("{0,-20} : {1,-10}", a,b);
The above code will output string left aligned, 20 or 10 for string a
and b. It true for English, but not for any CJK language.
If a or b are CJK string, it will never aligned. The reason is that
for Chinese (or Japanese, Korean), each character will occupy 2
alphabeta space (not only 2 byte for MBCS in memory). For example:
"$BCfJ8(B" will have same visual length with "abcd", however,
string.Format() will treat "$BCfJ8(B" as 2 chars, and "abcd" as 4 chars, so
string.Format() will padding "$BCfJ8(B" for 18 space, and 16 space for
"abcd" if we aligned by 20. So if we see the result, the "$BCfJ8(B" will
longer than "abcd" since over padding.
This is the problem I am facing. Is it a bug in .Net framework? or is
there anything wrong with me, and I could overcome it be setting any
culture info?
Thanks.