HighTechTalks DotNet Forums  

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

Dotnet Internationalization microsoft.public.dotnet.internationalization


Discuss What is the correct way of specifying mixed strings with parameters... in the Dotnet Internationalization forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Jochen Kalmbach
 
Posts: n/a

Default What is the correct way of specifying mixed strings with parameters... - 02-07-2005 , 08:52 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
http://blog.kalmbachnet.de/

Reply With Quote
  #2  
Old   
Michael \(michka\) Kaplan [MS]
 
Posts: n/a

Default Re: What is the correct way of specifying mixed strings with parameters... - 02-07-2005 , 11:49 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.



"Jochen Kalmbach" <nospam-Jochen.Kalmbach (AT) holzma (DOT) de> wrote

Quote:
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
http://blog.kalmbachnet.de/



Reply With Quote
  #3  
Old   
AT
 
Posts: n/a

Default Re: What is the correct way of specifying mixed strings with parameters... - 02-10-2005 , 08:47 PM



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...ectionalSuppor
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.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.