Problem with Polish accents with ASP.NET C#

A

AmigoFd

Hello,

This problem is really driving me crazy ...

* I have a mySql database which is latin1_swedish_ci

* In my web.config I have:
<globalization requestEncoding="ISO-8859-2"
responseEncoding="ISO-8859-2" fileEncoding="iso-8859-2" culture="pl-PL"
uiCulture="pl-PL" />

* My page has: <meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-2" />

* And when I insert text in the database I have a replace like this:
private static string CodeAccents(string doReCode) {
string rt = doReCode;

// dutch
rt = rt.Replace("ê","&ecirc;");
rt = rt.Replace("Ê","&Ecirc;");
rt = rt.Replace("ë","&euml;");
rt = rt.Replace("Ë","&Euml;");

// french
rt = rt.Replace("é","&eacute;");
rt = rt.Replace("É","&Eacute;");
rt = rt.Replace("è","&egrave;");
rt = rt.Replace("È","&Egrave;");
rt = rt.Replace("ê","&ecirc;");
rt = rt.Replace("Ê","&Ecirc;");
rt = rt.Replace("á","&aacute;");
rt = rt.Replace("Á","&Aacute;");
rt = rt.Replace("à","&agrave;");
rt = rt.Replace("À","&Agrave;");
rt = rt.Replace("ä","&auml;");
rt = rt.Replace("Ä","&Auml;");

// polish
rt = rt.Replace("A","&#260");
rt = rt.Replace("a","&#261");
rt = rt.Replace("C","&#262");
rt = rt.Replace("c","&#263");
rt = rt.Replace("E","&#280");
rt = rt.Replace("e","&#281");
rt = rt.Replace("L","&#321");
rt = rt.Replace("l","&#322");
rt = rt.Replace("N","&#323");
rt = rt.Replace("n","&#324");
rt = rt.Replace("Ó","&#211");
rt = rt.Replace("ó","&#243");
rt = rt.Replace("S","&#346");
rt = rt.Replace("s","&#347");
rt = rt.Replace("Z","&#377");
rt = rt.Replace("z","&#378");
rt = rt.Replace("Z","&#379");
rt = rt.Replace("z","&#380");

return rt;
}

Now, when I for instance save this word: "Zdjecia"

And I return to the form it is saved like "Zdj & # 2 8 1 cia" (spaces
added for posting here)

But when I then save again and retur I get this: "Zdjecia" = "# 3 7
7 dje & # 2 6 3 i & # 2 6 1" (spaces added for posting here)

What am I doing wrong ???

Thanks !
 
K

KJ

Looks like for the set of code below, the entities in the Polish
section lack a terminal semicolon. For example, you coded:

rt = rt.Replace("s","&#347");

and it should be

rt = rt.Replace("s","ś");

See the small difference ^^^

-KJ
 
A

AmigoFd

Problem found !!!

My code-page (.aspx) was saved as ANSI document and not as UTF-8 ! So
all my polish characters weren't saved at all, but were replaced by the
"normal" characters ... !

Have to check if that's a setting in dreamweaver ...


KJ schreef:
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top