Problem: Euro sign in sending email !

Discussion in 'ASP .Net' started by kingski, Mar 3, 2006.

  1. kingski

    kingski Guest

    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.
    kingski, Mar 3, 2006
    #1
    1. Advertising

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

    HTH...



    Juan T. Llibre, asp.net MVP
    aspnetfaq.com : http://www.aspnetfaq.com/
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "kingski" <> wrote in message news:%...
    > 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.
    Juan T. Llibre, Mar 3, 2006
    #2
    1. Advertising

  3. kingski

    Joerg Jooss Guest

    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,
    --
    Joerg Jooss
    Joerg Jooss, Mar 3, 2006
    #3
  4. 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.




    Juan T. Llibre, asp.net MVP
    aspnetfaq.com : http://www.aspnetfaq.com/
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "Joerg Jooss" <> wrote in message
    news:...
    > 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, --
    > Joerg Jooss
    >
    Juan T. Llibre, Mar 3, 2006
    #4
  5. kingski

    Joerg Jooss Guest

    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,
    --
    Joerg Jooss
    Joerg Jooss, Mar 4, 2006
    #5
  6. <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.




    Juan T. Llibre, asp.net MVP
    aspnetfaq.com : http://www.aspnetfaq.com/
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "Joerg Jooss" <> wrote in message
    news:...
    > 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,
    > --
    > Joerg Jooss
    >
    >
    >
    Juan T. Llibre, Mar 4, 2006
    #6
  7. kingski

    Joerg Jooss Guest

    Thus wrote Juan,

    > <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"


    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,
    --
    Joerg Jooss
    Joerg Jooss, Mar 4, 2006
    #7
  8. 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.




    Juan T. Llibre, asp.net MVP
    aspnetfaq.com : http://www.aspnetfaq.com/
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "Joerg Jooss" <> wrote in message
    news:...
    > Thus wrote Juan,
    >
    >> <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"

    >
    > 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,
    > Joerg Jooss
    Juan T. Llibre, Mar 4, 2006
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rphil

    Euro sign in .Net

    rphil, Apr 26, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    3,098
    Joerg Jooss
    Apr 28, 2005
  2. kingski

    Problem: Euro sign in send mail.

    kingski, Mar 3, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    417
    kingski
    Mar 3, 2006
  3. Marco W
    Replies:
    1
    Views:
    598
    David Carlisle
    Jun 8, 2005
  4. Yohan N. Leder
    Replies:
    11
    Views:
    987
    Jukka K. Korpela
    May 20, 2006
  5. Raga
    Replies:
    2
    Views:
    857
    Simon Brooke
    Oct 6, 2006
Loading...

Share This Page