By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,364 Members | 1,278 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,364 IT Pros & Developers. It's quick & easy.

Problem with Polish accents with ASP.NET C#

P: n/a
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 !

Aug 28 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

AmigoFd wrote:
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 !
Aug 29 '06 #2

P: n/a
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:
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

AmigoFd wrote:
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 !
Aug 29 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.