Groups | Blog | Home
all groups > dotnet internationalization > february 2005 >

dotnet internationalization : What is the correct way of specifying mixed strings with parameters...


Jochen Kalmbach
2/7/2005 5:52:44 AM
Hello,

I have a stupid qustion, but I am not able to find the correct way of
specifying an format-string which contains Right-to-Left strings...

Here is the string:

In english it should look like:
"Param1: {0}, Param2: {1}"

In hebrew it should look like:
"{1} :1maraP ,{0} :2maraP" (of course ":1maraP" and ":2maraP" is
hebrew!)

The first-Problem is, that I am not able to insert this string in an
textbox...

It always produces the following (or at least, it displays it):
"1} :2maraP ,{0} :1maraP}"

Ok, I managed to get this to work with a bad trick (just for example):

<code>
string hebrew = string.Empty;
hebrew += (char) 0x05D3;
hebrew += (char) 0x05E7;
hebrew += (char) 0x05D4;
this.textBox1.Text = "{1} :" + hebrew + " ,{0} :" + hebrew;
</code>

My second problem is now, that this only displays the correct stuff if it
contains numbers!!! If it contains english (or LTR characters) it
produces nonsence!!!:

With numbers (11111, and 22222):
"22222 :2maraP ,11111 :1maraP"

If I use RTL-Text with numbers ("111sdfsdf sdf11" and 22222) it produces
(displays):
"22222 :111, 2maraPsdfsdf sdf11 :1maraP"

What I want is:
"22222 :2maraP ,111sdfsdf sdf11 :1maraP"

<code>
this.textBox2.Text = string.Format(this.textBox4.Text, 11111, 22222);
this.textBox3.Text = string.Format(this.textBox4.Text,
"111sdfsdf sdf11", 22222);
</code>

How can this be accomplished!
Are there any markers, which can be used to represent an string-block?

I also want the string to be correct displayed if the parameter contains
mixed RTL and LTR-Text...

Any hints?

--
Greetings
Jochen

My blog about Win32 and .NET
Michael (michka) Kaplan [MS]
2/7/2005 8:49:29 PM
Maybe a string of characters like this?

U+05d0 U+05d1 U+05d4 U+0020 U+202d U+202e U+007b U+0030 U+007d

??? ??{0}

and so forth?

But this is just for appearanes. The truth is that the other string will
work just fine in the code that substitutes tokens....


--
MichKa [MS]
NLS Collation/Locale/Keyboard Technical Lead
Globalization Infrastructure, Fonts, and Tools
Microsoft Windows International Division

This posting is provided "AS IS" with
no warranties, and confers no rights.



[quoted text, click to view]

achimru NO[at]SPAM online.microsoft.com
2/11/2005 1:47:47 AM
Jochen,
what Michael mentions above is that you can embed directional formatting
codes in Unicode strings in cases where an external description of
directionality is not possible. E.g. in HTML it is and this is preferable
over inserting the formatting codes directly in the string. (U+202d =
Left-To-Right Override, U+202e = Right-To-Left Override)

This is, um, a bit complicated and described here:
http://www.unicode.org/reports/tr9/ (note that this is version is very new
and the Windows OS might not fully comply to all the details, but it will
in general). Also you should have your Windows Forms enabled for RTL
reading order in general:
http://msdn.microsoft.com/library/en-us/vbcon/html/vbconBi-directionalSuppor
tForWindowsApplications.asp?frame=true (this will change a bit in Whidbey)

Gruss
Achim Ruopp

--

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
AddThis Social Bookmark Button