Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

asp.net - accented French characters

Is there any problem with ASPX to render french accented characters?

I am using utf-8 to encode.

I never had any problem like this before (but since this is the first time I am working on an ASP server is there any fix?)

e.g événements = ?‰v??nements Journées fériées = Journ??es f??ri??es

Is this an encoding problem? or is there any specific code I need to place to render it correctly.

here is an example

The page reads:

Pour recevoir les communications de la€???cole par courriel, veuillez nous indiquer votre adresse courriel

It should read:

Pour recevoir les communications de l'école par courriel, veuillez nous indiquer votre adresse courriel
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

What's the problem, exactly? Have you set @Codepage=65001 in the page directives at the top of your file? Have you marked the content-type with the correct encoding so that the client knows what its getting?

If you see question marks, it's probable that you haven't set the response code page correctly. If you see two unrelated characters in place of a single character with a diacritic , you haven't told the client what it needs to know to treat the page as UTF-8, e.g.

Response.CodePage = 65001 ;
Response.CharSet = "utf-8" ;

There are slight differences between asp.net and asp handling of encoding, so it would also be helpful if you were more specific about which technology you're using, but that should get you most of the way there.

In ASP.Net, you can set the encoding site-wide in your web.config file, so you can avoid messing with Response.CodePage and Request.CodePage on every page. You still want to mark the Response Charset using the meta http-equiv content-type element in your HTML or using Response.Charset.

<globalization 
            requestEncoding="utf-8" 
            responseEncoding="utf-8"  />

If you don't want to use web.config for this for some reason, you'd use <%@CodePage=65001 %> in your .aspx file before you output any text, in the page directives.

It looks like the page in question contains incorrectly encoded UTF-8. Is the content coming straight from the .aspx file or is it being pulled from a database or something?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...