One aspx page to have utf-8 encoding

What should I do to change one aspx page to have utf-8 encoding?

my web.config has the following code:

<system.web>
  <globalization
     requestEncoding="utf-8"
     responseEncoding="utf-8"/>
</system.web>

Tried this:
meta http-equiv="Content-Type" content="text/html; charset=UTF-8"

doesn’t work.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Try this;

<configuration>
 <system.web>
  <globalization
    fileEncoding="utf-8" 
    requestEncoding="utf-8" 
    responseEncoding="utf-8"
    culture="en-US"
    uiCulture="de-DE"
   />
 </system.web>
</configuration>

To set the encoding for an individual page, set the RequestEncoding and ResponseEncoding attributes of the @ Page directive:
<%@ Page RequestEncoding="utf-8" ResponseEncoding="utf-8" %>

Or you can use location like this:
<location path="home.aspx">
    <system.web>
        <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
    </system.web>
</location>

Read more: How to: Select an Encoding for ASP.NET Web Page Globalization.

Method 2

Try to insert

Response.ContentEncoding = System.Text.Encoding.UTF8;

In your Page_Load if you want to do it dynamically.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x