Spanish Characters RRS feed

  • Question

  • User-2134249016 posted

     Hello Everyone,

    I'm having hard time displaying spanish characters in asp.net even if ive added a globalization section in my web.config which sets the encoding used to UTF-8:
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="auto" uiCulture="auto"/>

    The characters are being displayed if and only if I use:
    string encodedstring = Server.Encode(text);

    Am I missing something?


    Thank you in advance for your help


    Saturday, August 8, 2009 4:59 PM

All replies

  • User-25924017 posted

    The RequestEncoding property specifies the assumed encoding of each incoming HTTP request, including posted data and query-string data. If the request comes with a request header containing a ContentType field, the AcceptCharset field of the request header overrides the RequestEncoding of the configuration.

    So this could be the problem, 

    check in your webpage do you have:

    <title><var style="-webkit-box-sizing: border-box;">PageTitle</var></title>
    <meta http-equiv="Content-Type" content="text/html; charset=<var style="-webkit-box-sizing: border-box;" mce_style="-webkit-box-sizing: border-box;">CharacterSet</var>">
    here replace CharacterSet with the one you have in Web.Config i.e. UTF-8.
    if you do not have this tag then you can add after <Title> tag.
    Try it.

    Sunday, August 9, 2009 5:42 AM
  • User-2134249016 posted

    It didn't work!  It only works if I use server.htmlencode/decode! but there must be a solution for it!

    Sunday, August 9, 2009 10:44 AM
  • User-25924017 posted

    Strange, Try to set browser, encoding to "Auto" or Unicode(utf-8) and also try fileEncoding="utf-8" in web.config same as responseEncoding and requestEncoding.

    if you are displaying it in GridView then set HtmlEncode to false on column.

    Sunday, August 9, 2009 4:31 PM
  • User-25924017 posted

    BTW, what is the source of text (your data, is that encoded correctly)? and where you are displaying it?

    Sunday, August 9, 2009 4:33 PM
  • User-2134249016 posted

    Yes, I think the problem is not solved cuz the NLS_LANG of my DB is set to AMERICAN_AMERICA.AR8MSWIN1256 because I  have arabic data in my DB.

    So it's an ADO.NET problem, but how can I solve it?


    Sunday, August 9, 2009 4:40 PM
  • User-1739576956 posted

    Hmm.. I might be mistaken, but I'm not convinced that it's a db issue (HtmlEncoding does work as I understand you). Would it be possible for you to post a public url where we can access the site? I would like to take a look at how it's actually encoded at the hex level, so it would also help if you could somehow post the hex instead.

    Br. Morten

    Sunday, August 9, 2009 5:04 PM
  • User-2134249016 posted

    If the data is numerically encoded in the DB (e.g: &#241), the data is displayed correctly on the website without using HtmlDecode.

    Otherwise, if the data contains spanish special characters (e.g:  á ), a question mark is being displayed instead.

    Monday, August 10, 2009 2:56 AM
  • User-25924017 posted

    Okay, looking at this, what if you changes culture and UICulture from auto to "es-ES" or arbic (depeding on data). Does it work? Try it.

    Monday, August 10, 2009 4:58 AM
  • User-319574463 posted

    Within the database, is the string data stored as VARCHAR or NVARCHAR? String data needs to be stored as NVARCHAR or NCHAR.

    When inserting or updatting the data:

    • Use the correct NVARCHAR parameter type if using stored procedure
    • If using embedded TSQL, use the N prefix on literal strings as in:

    INSERT INTO FRED (A, B) VALUES (1, N'Hello World')

    Tuesday, August 11, 2009 11:58 AM
  • User-2134249016 posted

    they are stored as CLOB values. The character set of my db is not set to UTF8 but still it supports Latin characters. However, the spanish characters sent by the client  are not being ideintified and they are replaced by question marks...

    Tuesday, August 11, 2009 1:15 PM