Displaying Euro Symbol

G

Guest

I followed instructions in MSDN help articles and wrotethe folowing code in
order to display numeric numbers with Euro symbol as follows :
----------------------------
Dim OutString As [String] = ""
Dim frCulture As New CultureInfo("fr-FR", False)
Thread.CurrentThread.CurrentCulture = frCulture
Dim myCurrency As New [Decimal](123456)
myCurrency.ToString("C", LocalFormat)
OutString = "Euro : " + myCurrency.ToString("C",
NumberFormatInfo.CurrentInfo)
-----------------------------
Instead of getting
Euro : 123.456,00 €
The page is displaying
Euro : 123.456,00 ?
Am I missing a parameter somewhere?
Thanks
 
G

Guest

I is from this article I constructed my code. After I have posted my mail, I
rememebered that I gave changed the encoding in web.config from
<globalization fileEncoding="utf-8" requestEncoding="utf-8"
responseEncoding="utf-8"/>
To <globalization fileEncoding="ISO-85....." requestEncoding="ISO-85......."
responseEncoding="ISO-85........"/>
I swithed back to urf-8, now the Euro symbol displaying correctly.

Any ideas of why this?
Thanks
Juan T. Llibre said:
Hi, SalamElias

Take a look at this sample code :

http://msdn.microsoft.com/library/d...onformattingnumericdataforspecificculture.asp



Juan T. Llibre
===========
SalamElias said:
I followed instructions in MSDN help articles and wrotethe folowing code in
order to display numeric numbers with Euro symbol as follows :
----------------------------
Dim OutString As [String] = ""
Dim frCulture As New CultureInfo("fr-FR", False)
Thread.CurrentThread.CurrentCulture = frCulture
Dim myCurrency As New [Decimal](123456)
myCurrency.ToString("C", LocalFormat)
OutString = "Euro : " + myCurrency.ToString("C",
NumberFormatInfo.CurrentInfo)
-----------------------------
Instead of getting
Euro : 123.456,00 ?
The page is displaying
Euro : 123.456,00 ?
Am I missing a parameter somewhere?
Thanks
 
S

Steven Cheng[MSFT]

Hi SalamElias,

Thanks for your posting. I think the problem you mentioned is because the
"€" symbol which could be displayed correctly under UTF-8 encoding but
failed under "ISO-8859-1" is because
"€" is a three-bytes-character which can't be represented by ISO-8859-1(
Latin-1) charset, the ISO-8859-1 can only represent the standard
one-byte-charaters(0-127 is the standard ASCII CHARS). We can use the
following code to verify this;

Dim myCurrency As New [Decimal](123456)



Thread.CurrentThread.CurrentCulture = frCulture


Dim str As String = myCurrency.ToString("C",
NumberFormatInfo.CurrentInfo)
Dim flag As Char = str.Chars(str.Length - 1)

Response.Write("<br>" + flag.ToString())

Dim bytes() As Byte =
System.Text.Encoding.UTF8.GetBytes(flag.ToString())

Response.Write("<br>length: " & bytes.Length)

the length will return 3 indicate that it is a multi-bytes char.

If there is anything unclear, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
J

Joerg Jooss

Steven said:
Hi SalamElias,

Thanks for your posting. I think the problem you mentioned is because
the "€" symbol which could be displayed correctly under UTF-8
encoding but failed under "ISO-8859-1" is because
"€" is a three-bytes-character which can't be represented by
ISO-8859-1( Latin-1) charset, the ISO-8859-1 can only represent the
standard one-byte-charaters(0-127 is the standard ASCII CHARS). We
can use the following code to verify this;

There's no concept of multibyte characters in ISO-8859-x -- these are simply
8 bit encodings, and ISO-8859-1 simply doesn't ccontain €. It is contained
in ISO-8859-15, but using UTF-8 should be the preferred solution anyway.

Cheers,
 
S

Steven Cheng[MSFT]

Hi Joerg,

Thanks a lot for your correction. Yes, I think I've mistaken the "€" char
for a multi-bytes one. Your point on the ISO-8859-x highlight this. Thank
again for your input.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top