Problem: Euro sign in sending email !

K

kingski

Any idea about this ?
http://www.developerfusion.co.uk/forums/thread/114379/#114379

"Can any one help me as i am building a shopping cart and it supports
multiple currencies but while sending confirmation mail o customer it does
not show euro sign before amount he paid but it is showing a queston mark
over there. It is working fine with Dollar sign and Pound Sign but this Euro
is creating problem. "

thanks.
 
J

Juan T. Llibre

In web.config, set the <globalization/> element's responseEncoding attribute
to an encoding which includes the Euro sign.

If you are writing files, set the fileEncoding, too.
If you are reading files, set the requestEncoding, too.

Also, make sure your browser is set to auto-detect encoding.

If the browser is set to a fixed encoding, it will use whatever it's set for,
instead of UTF-8, which is the default for the .Net Framework.

I use iso-8859-1 and that displays the Euro.
See : http://asp.net.do/test/EuroCurrency.aspx

You may need to set the correct culture, too, if you're using currency.


Here's the code for that page :

<%@ Page language="C#" debug="true" %>
<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="System.Threading" %>

<html>
<head>
<SCRIPT runat="server">

void Page_Load(){
String OutString = "";
CultureInfo DeCulture = new CultureInfo("de-DE", false);
Thread.CurrentThread.CurrentCulture = DeCulture;

NumberFormatInfo LocalFormat = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();
LocalFormat.CurrencySymbol = "DM"; // Replace currency symbol with DM sign.

Decimal myCurrency = new Decimal( 123456 );

myCurrency.ToString( "C", LocalFormat );

OutString = "Euro : " + myCurrency.ToString( "C", NumberFormatInfo.CurrentInfo );
OutString += "<br>" + "German Mark : " + myCurrency.ToString( "C", LocalFormat );

CultureInfo EnUSCulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = EnUSCulture;
OutString += "<br>" + "US Dollar : " + myCurrency.ToString( "C", NumberFormatInfo.CurrentInfo );

CultureInfo esDOCulture = new CultureInfo("es-DO");
Thread.CurrentThread.CurrentCulture = esDOCulture;
OutString += "<br>" + "Dominican Peso : " + myCurrency.ToString("C", NumberFormatInfo.CurrentInfo);

CultureInfo nnNOCulture = new CultureInfo("nn-NO");
Thread.CurrentThread.CurrentCulture = nnNOCulture;
OutString += "<br>" + "Norwegian Krone : " + myCurrency.ToString("C", NumberFormatInfo.CurrentInfo);

Response.Write( OutString );

}
</SCRIPT>
</head>

<body>
</body>
</html>
 
J

Joerg Jooss

Thus wrote Juan,
In web.config, set the <globalization/> element's responseEncoding
attribute to an encoding which includes the Euro sign.

If you are writing files, set the fileEncoding, too. If you are
reading files, set the requestEncoding, too.

Also, make sure your browser is set to auto-detect encoding.

If the browser is set to a fixed encoding, it will use whatever it's
set for, instead of UTF-8, which is the default for the .Net
Framework.

I use iso-8859-1 and that displays the Euro.

ISO-8859-1 *does not* include the €. That's one of the reasons why we have
ISO-8859-15 among the ISO 8 bit encodings.

See also http://en.wikipedia.org/wiki/ISO_8859-1

Cheers,
 
J

Juan T. Llibre

Well, the page at http://asp.net.do/test/EuroCurrency.aspx
uses iso-8859-1 and displays the Euro, so I'm a bit mystified.

How coulde that happen, if iso-8859-1 doesn't include the Euro symbol ?

Here's the web.config for that file :

<globalization
requestEncoding="iso-8859-1"
responseEncoding="iso-8859-1"
fileEncoding="iso-8859-1"
culture="es-DO"
uiCulture="es-DO"
/>

Maybe Windows or .Net use a superset of the iso-8859-1 standard ?

My Regional settings are set to English/US, btw.
 
J

Joerg Jooss

Thus wrote Juan,
Well, the page at http://asp.net.do/test/EuroCurrency.aspx uses
iso-8859-1 and displays the Euro, so I'm a bit mystified.

How coulde that happen, if iso-8859-1 doesn't include the Euro symbol
?

Here's the web.config for that file :

<globalization
requestEncoding="iso-8859-1"
responseEncoding="iso-8859-1"
fileEncoding="iso-8859-1"
culture="es-DO"
uiCulture="es-DO"
/>
Maybe Windows or .Net use a superset of the iso-8859-1 standard ?

No, the answer is much simpler, though rather puzzling given your web.config
snippet: Your page uses UTF-8.

Here is what's actually being sent from your page in bytes: E2 82 AC -- which
is € encoded by UTF-8.

And BTW, check your browser: If it's set to auto detect encoding, it'll show
UTF-8 as encoding. Or manually switch to ISO-8859-1 to see the € go away.
Or use my sample ;-)

Cheers,
 
J

Juan T. Llibre

<sigh>

That's twice I've stubbed my toe on that.
Thanks, Joerg.

re:
Here is what's actually being sent from your page in bytes: E2 82 AC -- which is ? encoded by
UTF-8.

I'm still having a hard time understanding how "Auto-Select"
could possible read the page's encoding as UTF-8,
when it's being encoded and sent by the server as iso-8859-1 :
requestEncoding="iso-8859-1"
responseEncoding="iso-8859-1"
fileEncoding="iso-8859-1"

I'm encouraged by this comment of yours :
"rather puzzling given your web.config snippet"

Indeed, Joerg, it's "rather puzzling" since encoding doesn't
occur by osmosis nor by browser intervention.

Again, I'm having a hard time understanding how my server can send UTF-8,
to be read by the browser as UTF-8, when everything is being encoded as iso-8859-1.
 
J

Joerg Jooss

Thus wrote Juan,
<sigh>

That's twice I've stubbed my toe on that.
Thanks, Joerg.
re:

I'm still having a hard time understanding how "Auto-Select"
could possible read the page's encoding as UTF-8,
when it's being encoded and sent by the server as iso-8859-1 :

Well, the browser recognizes the encoding by parsing the charset attribute
of the Content-Type header:
Content-Type: text/xml; charset=utf-8
I'm encouraged by this comment of yours :
"rather puzzling given your web.config snippet"
Indeed, Joerg, it's "rather puzzling" since encoding doesn't occur by
osmosis nor by browser intervention.

It has to be some broken configuration on your side. If I run your page on
my machine and change web.config accordingly, the output is missing the €,
as expected. Whatever happens on your server, this particular page uses UTF-8.

Cheers,
 
J

Juan T. Llibre

re:
Whatever happens on your server, this particular page uses UTF-8.

I feel like an ass.

I had done some tests ( that's why the virtual dir is called "test" );
had commented out the iso-8859-1 config and was actually using utf-8.

Thanks for your assistance.
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top