Carrey Mu

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 今天公司站点遇到个问题:因为数据库设置的编码是GB的,所以一些法语字符存进去后立马乱码,更别说显示了,所以我想到了西文字符的显示方式。

如果你安装了DW,可以将首选参数的默认编码设置为希腊文,新建一个HTML页面你可以看到charset=iso-8859-7,OK,将其改为charset=iso-8859-1即可。

在拆分的下面输入框中输入汉字,嘿嘿,看到上面HTML框的一侧出现什么了吗?你好代表的就是:你好,而且还有个好处是含这种编码的HTML的

页面无论使用什么编码方式的浏览器打开你会发现都不会乱码,汉字依然是汉字,真是强悍!想必UTF都应该会自叹不如吧。

回到正题,在百度里找了半天,没查到有用的信息,到是Google第一页就找到了有用的信息(BS百度),如果用iso-8859-1可以达到目的那么就直接用这个来替换

吧,下面一段代码就是全部特殊字符的替换代码具体的应该成为扩展ASCII码:

View Code
#region ConvertAllSpecialCharactor
        /// <summary>
        /// 替换全部ASCII字符
        /// </summary>
        /// <param name="pValue"></param>
        /// <returns></returns>
        public static String ConvertAllSpecialCharactor(String pValue)
        {
            pValue = pValue.Replace("", "&#8364;");
            pValue = pValue.Replace("", "&#8218;");
            pValue = pValue.Replace("ƒ", "&#402;");
            pValue = pValue.Replace("", "&#8222;");
            pValue = pValue.Replace("", "&#8230;");
            pValue = pValue.Replace("", "&#8224;");
            pValue = pValue.Replace("", "&#8225;");
            pValue = pValue.Replace("ˆ", "&#710;");
            pValue = pValue.Replace("", "&#8240;");
            pValue = pValue.Replace("Š", "&#352;");
            pValue = pValue.Replace("", "&#8249;");
            pValue = pValue.Replace("Œ", "&#338;");
            pValue = pValue.Replace("Ž", "&#381;");
            pValue = pValue.Replace("", "&#8216;");
            pValue = pValue.Replace("", "&#8364;");
            pValue = pValue.Replace("", "&#8220;");
            pValue = pValue.Replace("", "&#8221;");
            pValue = pValue.Replace("", "&#8226;");
            pValue = pValue.Replace("", "&#8211;");
            pValue = pValue.Replace("", "&#8212;");
            pValue = pValue.Replace("˜", "&#732;");
            pValue = pValue.Replace("", "&#8482;");
            pValue = pValue.Replace("š", "&#353;");
            pValue = pValue.Replace("", "&#8250;");
            pValue = pValue.Replace("œ", "&#339;");
            pValue = pValue.Replace("ž", "&#382;");
            pValue = pValue.Replace("Ÿ", "&#376;");
            pValue = pValue.Replace("¡", "&#161;");
            pValue = pValue.Replace("¢", "&#162;");
            pValue = pValue.Replace("£", "&#163;");
            pValue = pValue.Replace("¤", "&#164;");
            pValue = pValue.Replace("¥", "&#165;");
            pValue = pValue.Replace("¦", "&#166;");
            pValue = pValue.Replace("§", "&#167;");
            pValue = pValue.Replace("¨", "&#168;");
            pValue = pValue.Replace("©", "&#169;");
            pValue = pValue.Replace("ª", "&#170;");
            pValue = pValue.Replace("«", "&#171;");
            pValue = pValue.Replace("¬", "&#172;");
            pValue = pValue.Replace("®", "&#174;");
            pValue = pValue.Replace("¯", "&#175;");
            pValue = pValue.Replace("°", "&#176;");
            pValue = pValue.Replace("±", "&#177;");
            pValue = pValue.Replace("²", "&#178;");
            pValue = pValue.Replace("³", "&#179;");
            pValue = pValue.Replace("´", "&#180;");
            pValue = pValue.Replace("µ", "&#181;");
            pValue = pValue.Replace("", "&#182;");
            pValue = pValue.Replace("·", "&#183;");
            pValue = pValue.Replace("¸", "&#184;");
            pValue = pValue.Replace("¹", "&#185;");
            pValue = pValue.Replace("º", "&#186;");
            pValue = pValue.Replace("»", "&#187;");
            pValue = pValue.Replace("¼", "&#188;");
            pValue = pValue.Replace("½", "&#189;");
            pValue = pValue.Replace("¾", "&#190;");
            pValue = pValue.Replace("¿", "&#191;");
            pValue = pValue.Replace("À", "&#192;");
            pValue = pValue.Replace("Á", "&#193;");
            pValue = pValue.Replace("Â", "&#194;");
            pValue = pValue.Replace("Ã", "&#195;");
            pValue = pValue.Replace("Ä", "&#196;");
            pValue = pValue.Replace("Å", "&#197;");
            pValue = pValue.Replace("Æ", "&#198;");
            pValue = pValue.Replace("Ç", "&#199;");
            pValue = pValue.Replace("È", "&#200;");
            pValue = pValue.Replace("É", "&#201;");
            pValue = pValue.Replace("Ê", "&#202;");
            pValue = pValue.Replace("Ë", "&#203;");
            pValue = pValue.Replace("Ì", "&#204;");
            pValue = pValue.Replace("Í", "&#205;");
            pValue = pValue.Replace("Î", "&#206;");
            pValue = pValue.Replace("Ï", "&#207;");
            pValue = pValue.Replace("Ð", "&#208;");
            pValue = pValue.Replace("Ñ", "&#209;");
            pValue = pValue.Replace("Ò", "&#210;");
            pValue = pValue.Replace("Ó", "&#211;");
            pValue = pValue.Replace("Ô", "&#212;");
            pValue = pValue.Replace("Õ", "&#213;");
            pValue = pValue.Replace("Ö", "&#214;");
            pValue = pValue.Replace("×", "&#215;");
            pValue = pValue.Replace("Ø", "&#216;");
            pValue = pValue.Replace("Ù", "&#217;");
            pValue = pValue.Replace("Ú", "&#218;");
            pValue = pValue.Replace("Û", "&#219;");
            pValue = pValue.Replace("Ü", "&#220;");
            pValue = pValue.Replace("Ý", "&#221;");
            pValue = pValue.Replace("Þ", "&#222;");
            pValue = pValue.Replace("ß", "&#223;");
            pValue = pValue.Replace("à", "&#224;");
            pValue = pValue.Replace("á", "&#225;");
            pValue = pValue.Replace("â", "&#226;");
            pValue = pValue.Replace("ã", "&#227;");
            pValue = pValue.Replace("ä", "&#228;");
            pValue = pValue.Replace("å", "&#229;");
            pValue = pValue.Replace("æ", "&#230;");
            pValue = pValue.Replace("ç", "&#231;");
            pValue = pValue.Replace("è", "&#232;");
            pValue = pValue.Replace("é", "&#233;");
            pValue = pValue.Replace("ê", "&#234;");
            pValue = pValue.Replace("ë", "&#235;");
            pValue = pValue.Replace("ì", "&#236;");
            pValue = pValue.Replace("í", "&#237;");
            pValue = pValue.Replace("î", "&#238;");
            pValue = pValue.Replace("ï", "&#239;");
            pValue = pValue.Replace("ð", "&#240;");
            pValue = pValue.Replace("ñ", "&#241;");
            pValue = pValue.Replace("ò", "&#242;");
            pValue = pValue.Replace("ó", "&#243;");
            pValue = pValue.Replace("ô", "&#244;");
            pValue = pValue.Replace("õ", "&#245;");
            pValue = pValue.Replace("ö", "&#246;");
            pValue = pValue.Replace("÷", "&#247;");
            pValue = pValue.Replace("ø", "&#248;");
            pValue = pValue.Replace("ù", "&#249;");
            pValue = pValue.Replace("ú", "&#250;");
            pValue = pValue.Replace("û", "&#251;");
            pValue = pValue.Replace("ü", "&#252;");
            pValue = pValue.Replace("ý", "&#253;");
            pValue = pValue.Replace("þ", "&#254;");
            pValue = pValue.Replace("ÿ", "&#255;");
            return pValue;
        }
        #endregion

将ASCII码转换为特殊字符:

View Code
#region DSpecialCharactorConvertAll
        /// <summary>
        /// 将编码转换为特殊字符
        /// </summary>
        /// <param name="pValue">要替换的字符串</param>
        /// <returns></returns>
        public static String DConvertAllSpecialCharactor(String pValue)
        {
            pValue = pValue.Replace("&#8364;", "");
            pValue = pValue.Replace("&#8218;", "");
            pValue = pValue.Replace("&#402;", "ƒ");
            pValue = pValue.Replace("&#8222;", "");
            pValue = pValue.Replace("&#8230;", "");
            pValue = pValue.Replace("&#8224;", "");
            pValue = pValue.Replace("&#8225;", "");
            pValue = pValue.Replace("&#710;", "ˆ");
            pValue = pValue.Replace("&#8240;", "");
            pValue = pValue.Replace("&#352;", "Š");
            pValue = pValue.Replace("&#8249;", "");
            pValue = pValue.Replace("&#338;", "Œ");
            pValue = pValue.Replace("&#381;", "Ž");
            pValue = pValue.Replace("&#8216;", "");
            pValue = pValue.Replace("&#8364;", "");
            pValue = pValue.Replace("&#8220;", "");
            pValue = pValue.Replace("&#8221;", "");
            pValue = pValue.Replace("&#8226;", "");
            pValue = pValue.Replace("&#8211;", "");
            pValue = pValue.Replace("&#8212;", "");
            pValue = pValue.Replace("&#732;", "˜");
            pValue = pValue.Replace("&#8482;", "");
            pValue = pValue.Replace("&#353;", "š");
            pValue = pValue.Replace("&#8250;", "");
            pValue = pValue.Replace("&#339;", "œ");
            pValue = pValue.Replace("&#382;", "ž");
            pValue = pValue.Replace("&#376;", "Ÿ");
            pValue = pValue.Replace("&#161;", "¡");
            pValue = pValue.Replace("&#162;", "¢");
            pValue = pValue.Replace("&#163;", "£");
            pValue = pValue.Replace("&#164;", "¤");
            pValue = pValue.Replace("&#165;", "¥");
            pValue = pValue.Replace("&#166;", "¦");
            pValue = pValue.Replace("&#167;", "§");
            pValue = pValue.Replace("&#168;", "¨");
            pValue = pValue.Replace("&#169;", "©");
            pValue = pValue.Replace("&#170;", "ª");
            pValue = pValue.Replace("&#171;", "«");
            pValue = pValue.Replace("&#172;", "¬");
            pValue = pValue.Replace("&#173;", "");
            pValue = pValue.Replace("&#174;", "®");
            pValue = pValue.Replace("&#175;", "¯");
            pValue = pValue.Replace("&#176;", "°");
            pValue = pValue.Replace("&#177;", "±");
            pValue = pValue.Replace("&#178;", "²");
            pValue = pValue.Replace("&#179;", "³");
            pValue = pValue.Replace("&#180;", "´");
            pValue = pValue.Replace("&#181;", "µ");
            pValue = pValue.Replace("&#182;", "");
            pValue = pValue.Replace("&#183;", "·");
            pValue = pValue.Replace("&#184;", "¸");
            pValue = pValue.Replace("&#185;", "¹");
            pValue = pValue.Replace("&#186;", "º");
            pValue = pValue.Replace("&#187;", "»");
            pValue = pValue.Replace("&#188;", "¼");
            pValue = pValue.Replace("&#189;", "½");
            pValue = pValue.Replace("&#190;", "¾");
            pValue = pValue.Replace("&#191;", "¿");
            pValue = pValue.Replace("&#192;", "À");
            pValue = pValue.Replace("&#193;", "Á");
            pValue = pValue.Replace("&#194;", "Â");
            pValue = pValue.Replace("&#195;", "Ã");
            pValue = pValue.Replace("&#196;", "Ä");
            pValue = pValue.Replace("&#197;", "Å");
            pValue = pValue.Replace("&#198;", "Æ");
            pValue = pValue.Replace("&#199;", "Ç");
            pValue = pValue.Replace("&#200;", "È");
            pValue = pValue.Replace("&#201;", "É");
            pValue = pValue.Replace("&#202;", "Ê");
            pValue = pValue.Replace("&#203;", "Ë");
            pValue = pValue.Replace("&#204;", "Ì");
            pValue = pValue.Replace("&#205;", "Í");
            pValue = pValue.Replace("&#206;", "Î");
            pValue = pValue.Replace("&#207;", "Ï");
            pValue = pValue.Replace("&#208;", "Ð");
            pValue = pValue.Replace("&#209;", "Ñ");
            pValue = pValue.Replace("&#210;", "Ò");
            pValue = pValue.Replace("&#211;", "Ó");
            pValue = pValue.Replace("&#212;", "Ô");
            pValue = pValue.Replace("&#213;", "Õ");
            pValue = pValue.Replace("&#214;", "Ö");
            pValue = pValue.Replace("&#215;", "×");
            pValue = pValue.Replace("&#216;", "Ø");
            pValue = pValue.Replace("&#217;", "Ù");
            pValue = pValue.Replace("&#218;", "Ú");
            pValue = pValue.Replace("&#219;", "Û");
            pValue = pValue.Replace("&#220;", "Ü");
            pValue = pValue.Replace("&#221;", "Ý");
            pValue = pValue.Replace("&#222;", "Þ");
            pValue = pValue.Replace("&#223;", "ß");
            pValue = pValue.Replace("&#224;", "à");
            pValue = pValue.Replace("&#225;", "á");
            pValue = pValue.Replace("&#226;", "â");
            pValue = pValue.Replace("&#227;", "ã");
            pValue = pValue.Replace("&#228;", "ä");
            pValue = pValue.Replace("&#229;", "å");
            pValue = pValue.Replace("&#230;", "æ");
            pValue = pValue.Replace("&#231;", "ç");
            pValue = pValue.Replace("&#232;", "è");
            pValue = pValue.Replace("&#233;", "é");
            pValue = pValue.Replace("&#234;", "ê");
            pValue = pValue.Replace("&#235;", "ë");
            pValue = pValue.Replace("&#236;", "ì");
            pValue = pValue.Replace("&#237;", "í");
            pValue = pValue.Replace("&#238;", "î");
            pValue = pValue.Replace("&#239;", "ï");
            pValue = pValue.Replace("&#240;", "ð");
            pValue = pValue.Replace("&#241;", "ñ");
            pValue = pValue.Replace("&#242;", "ò");
            pValue = pValue.Replace("&#243;", "ó");
            pValue = pValue.Replace("&#244;", "ô");
            pValue = pValue.Replace("&#245;", "õ");
            pValue = pValue.Replace("&#246;", "ö");
            pValue = pValue.Replace("&#247;", "÷");
            pValue = pValue.Replace("&#248;", "ø");
            pValue = pValue.Replace("&#249;", "ù");
            pValue = pValue.Replace("&#250;", "ú");
            pValue = pValue.Replace("&#251;", "û");
            pValue = pValue.Replace("&#252;", "ü");
            pValue = pValue.Replace("&#253;", "ý");
            pValue = pValue.Replace("&#254;", "þ");
            pValue = pValue.Replace("&#255;", "ÿ");
            pValue = pValue.Replace("&Agrave;", "À");
            pValue = pValue.Replace("&Aacute;", "Á");
            pValue = pValue.Replace("&Acirc;", "Â");
            pValue = pValue.Replace("&Atilde;", "Ã");
            pValue = pValue.Replace("&Auml;", "Ä");
            pValue = pValue.Replace("&Aring;", "Å");
            pValue = pValue.Replace("&AElig;", "Æ");
            pValue = pValue.Replace("&Ccedil;", "Ç");
            pValue = pValue.Replace("&Egrave;", "È");
            pValue = pValue.Replace("&Eacute;", "É");
            pValue = pValue.Replace("&Ecirc;", "Ê");
            pValue = pValue.Replace("&Euml;", "Ë");
            pValue = pValue.Replace("&Igrave;", "Ì");
            pValue = pValue.Replace("&Iacute;", "Í");
            pValue = pValue.Replace("&Icirc;", "Î");
            pValue = pValue.Replace("&Iuml;", "Ï");
            pValue = pValue.Replace("&ETH;", "Ð");
            pValue = pValue.Replace("&Ntilde;", "Ñ");
            pValue = pValue.Replace("&Otilde;", "Õ");
            pValue = pValue.Replace("&Ouml;", "Ö");
            pValue = pValue.Replace("&Oslash;", "Ø");
            pValue = pValue.Replace("&copy;", "©");
            pValue = pValue.Replace("&reg;", "®");
            return pValue;
        }
        #endregion

重要的地方来了!默认的MSSQL是识别一些特殊字符的所以并不需要替换,下面就给出了数据库表识别的特殊字符

View Code
#region ConvertSomeSpecialCharactor
        /// <summary>
        /// 将特殊字符转换为编码  用于MSSQL不识别
        /// </summary>
        /// <param name="pValue">要替换的字符串</param>
        /// <returns></returns>
        public static String ConvertSomeSpecialCharactor(String pValue)
        {
            pValue = pValue.Replace("", "&#130;");
            pValue = pValue.Replace("ƒ", "&#131;");
            pValue = pValue.Replace("", "&#132;");
            pValue = pValue.Replace("", "&#134;");
            pValue = pValue.Replace("", "&#135;");
            pValue = pValue.Replace("ˆ", "&#136;");
            pValue = pValue.Replace("Š", "&#138;");
            pValue = pValue.Replace("", "&#139;");
            pValue = pValue.Replace("Œ", "&#140;");
            pValue = pValue.Replace("Ž", "&#142;");
            pValue = pValue.Replace("", "&#149;");
            pValue = pValue.Replace("˜", "&#152;");
            pValue = pValue.Replace("", "&#153;");
            pValue = pValue.Replace("š", "&#154;");
            pValue = pValue.Replace("", "&#155;");
            pValue = pValue.Replace("œ", "&#156;");
            pValue = pValue.Replace("ž", "&#158;");
            pValue = pValue.Replace("Ÿ", "&#159;");
            pValue = pValue.Replace("¡", "&#161;");
            pValue = pValue.Replace("¢", "&#162;");
            pValue = pValue.Replace("©", "&#169;");
            pValue = pValue.Replace("«", "&#171;");
            pValue = pValue.Replace("¬", "&#172;");
            pValue = pValue.Replace("®", "&#174;");
            pValue = pValue.Replace("", "&#182;");
            pValue = pValue.Replace("¸", "&#184;");
            pValue = pValue.Replace("»", "&#187;");
            pValue = pValue.Replace("¼", "&#188;");
            pValue = pValue.Replace("½", "&#189;");
            pValue = pValue.Replace("¾", "&#190;");
            pValue = pValue.Replace("¿", "&#191;");
            pValue = pValue.Replace("Â", "&#194;");
            pValue = pValue.Replace("Ã", "&#195;");
            pValue = pValue.Replace("Ä", "&#196;");
            pValue = pValue.Replace("Å", "&#197;");
            pValue = pValue.Replace("Æ", "&#198;");
            pValue = pValue.Replace("Ç", "&#199;");
            pValue = pValue.Replace("Ë", "&#203;");
            pValue = pValue.Replace("Î", "&#206;");
            pValue = pValue.Replace("Ï", "&#207;");
            pValue = pValue.Replace("Ð", "&#208;");
            pValue = pValue.Replace("Ñ", "&#209;");
            pValue = pValue.Replace("Ô", "&#212;");
            pValue = pValue.Replace("Õ", "&#213;");
            pValue = pValue.Replace("Ö", "&#214;");
            pValue = pValue.Replace("Ø", "&#216;");
            pValue = pValue.Replace("Û", "&#219;");
            pValue = pValue.Replace("Ý", "&#221;");
            pValue = pValue.Replace("Þ", "&#222;");
            pValue = pValue.Replace("ß", "&#223;");
            pValue = pValue.Replace("â", "&#226;");
            pValue = pValue.Replace("ã", "&#227;");
            pValue = pValue.Replace("ä", "&#228;");
            pValue = pValue.Replace("å", "&#229;");
            pValue = pValue.Replace("æ", "&#230;");
            pValue = pValue.Replace("ç", "&#231;");
            pValue = pValue.Replace("ë", "&#235;");
            pValue = pValue.Replace("î", "&#238;");
            pValue = pValue.Replace("ï", "&#239;");
            pValue = pValue.Replace("ð", "&#240;");
            pValue = pValue.Replace("ñ", "&#241;");
            pValue = pValue.Replace("ô", "&#244;");
            pValue = pValue.Replace("õ", "&#245;");
            pValue = pValue.Replace("ö", "&#246;");
            pValue = pValue.Replace("ø", "&#248;");
            pValue = pValue.Replace("û", "&#251;");
            pValue = pValue.Replace("ü", "&#252;");
            pValue = pValue.Replace("ý", "&#253;");
            pValue = pValue.Replace("þ", "&#254;");
            pValue = pValue.Replace("ÿ", "&#255;");

            return pValue;
        }
        #endregion

那么这些鸟文到底除了法语之外还有什么用呢?查了一下ISO-8859-1,矮马,吓一跳!现在发现上段代码多么可爱了,竟然可以解决下面语言的乱码显示问题。

此字符集支持部分于欧洲使用的语言,包括阿尔巴尼亚语、巴斯克语、布列塔尼语、加泰罗尼亚语、丹麦语、荷兰语、法罗语、弗里西语、加利西亚语、德语、格陵兰语、冰岛语、爱尔兰盖尔语、意大利语、拉丁语、卢森堡语、挪威语、葡萄牙语、里托罗曼斯语、苏格兰盖尔语、西班牙语及瑞典语。

英语虽然没有重音字母,但仍会标明为ISO/IEC 8859-1编码。除此之外,欧洲以外的部分语言,如南非荷兰语、斯瓦希里语、印尼语及马来语、菲律宾他加洛语等也可使用ISO/IEC 8859-1编码。

法语及芬兰语本来也使用ISO/IEC 8859-1来表示。ISO 8859-15同时加入了欧元符号。

这么多字符一个个替换想必效率很慢,如果我只是需要其中的一些热门语言呢?比如法德意葡西拉丁等呢?

OK,我必须有一次BS一下度娘了,找了半天没我要的信息,商业信息真TM多,有用的站点出现了http://www.dadeyu.com/

对应的我整理了French、Italian、German、Spanish、Portuguese、Latin的一些特殊字符,但是我实在不知道这些国家的键盘上会蹦出什么特殊的符号,所以法

语的就附加了俩,其他待网友补充吧。

View Code
 1 public static String ConvertHotlanguageToSpecialCharactorConvert(String pValue)
 2         {
 3 
 4             //French  
 5             pValue = pValue.Replace("Œ", "&#140;");
 6             pValue = pValue.Replace("À", "&#192;");
 7             pValue = pValue.Replace("Â", "&#194;");
 8             pValue = pValue.Replace("Ç", "&#199;");
 9             pValue = pValue.Replace("È", "&#200;");
10             pValue = pValue.Replace("É", "&#201;");
11             pValue = pValue.Replace("Ê", "&#202;");
12             pValue = pValue.Replace("Ë", "&#203;");
13             pValue = pValue.Replace("Î", "&#206;");
14             pValue = pValue.Replace("Ï", "&#207;");
15             pValue = pValue.Replace("Ô", "&#212;");
16             pValue = pValue.Replace("Ù", "&#217;");
17             pValue = pValue.Replace("Û", "&#219;");
18             pValue = pValue.Replace("œ", "&#156;");
19             pValue = pValue.Replace("à", "&#224;");
20             pValue = pValue.Replace("â", "&#226;");
21             pValue = pValue.Replace("ç", "&#231;");
22             pValue = pValue.Replace("è", "&#232;");
23             pValue = pValue.Replace("é", "&#233;");
24             pValue = pValue.Replace("ê", "&#234;");
25             pValue = pValue.Replace("ë", "&#235;");
26             pValue = pValue.Replace("î", "&#238;");
27             pValue = pValue.Replace("ï", "&#239;");
28             pValue = pValue.Replace("ô", "&#244;");
29             pValue = pValue.Replace("ù", "&#249;");
30             pValue = pValue.Replace("û", "&#251;");
31 
32             pValue = pValue.Replace("§", "&#167;");
33             pValue = pValue.Replace("", "&#128;");
34             pValue = pValue.Replace("", "&#133;");
35 
36             //Italian
37             pValue = pValue.Replace("Ì", "&#204;");
38             pValue = pValue.Replace("Í", "&#205;");
39             pValue = pValue.Replace("ì", "&#236;");
40             pValue = pValue.Replace("í", "&#237;");
41             pValue = pValue.Replace("Ò", "&#210;");
42             pValue = pValue.Replace("Ó", "&#211;");
43             pValue = pValue.Replace("ò", "&#242;");
44             pValue = pValue.Replace("ó", "&#243;");
45             pValue = pValue.Replace("Ú", "&#218;");
46             pValue = pValue.Replace("ú", "&#250;");
47 
48             //German
49             pValue = pValue.Replace("ä", "&#228;");
50             pValue = pValue.Replace("Ä", "&#196;");
51             pValue = pValue.Replace("ü", "&#252;");
52             pValue = pValue.Replace("Ü", "&#220;");
53             pValue = pValue.Replace("ö", "&#246;");
54             pValue = pValue.Replace("Ö", "&#214;");
55             pValue = pValue.Replace("ß", "&#223;");
56 
57             //Spanish
58             pValue = pValue.Replace("ñ", "&#241;");
59             pValue = pValue.Replace("Ñ", "&#209;");
60             pValue = pValue.Replace("Á", "&#193;");
61             pValue = pValue.Replace("á", "&#225;");
62             pValue = pValue.Replace("Ó", "&#211;");
63             pValue = pValue.Replace("ó", "&#243;");
64 
65             pValue = pValue.Replace("¿", "&#191;");
66             pValue = pValue.Replace("¡", "&#161;");
67 
68             //Portuguese
69             pValue = pValue.Replace("Ã", "&#195;");
70             pValue = pValue.Replace("ã", "&#227;");
71             pValue = pValue.Replace("Õ", "&#213;");
72             pValue = pValue.Replace("õ", "&#245;");
73 
74             //Latin
75             pValue = pValue.Replace("æ", "&#230;");
76             pValue = pValue.Replace("Æ", "&#198;");
77 
78             return pValue;
79         }

提到8859的字符编码就会让人想起搜索引擎的SEO优化,因为汉字都被替换成&#***;了所以对于谷歌和度娘来说都是问题(个人认为),所以解决方案就是如果不是

大问题就用UTF-8,如果碰到如德意等国含有特殊字符,奉劝还是用UTF-8,将特殊字符用 &#***;替换掉,让文字能够正常显示,起码搜索引擎会对站点比较友好

您说呢?

另外提供一些扩展ASCII的对比表(度娘愣是找不到)

 
ASCII: 32
HTML:
URL: +
!
ASCII: 33
HTML: !
URL: %21
"
ASCII: 34
HTML: &quot;
URL: %22
#
ASCII: 35
HTML: #
URL: %23
$
ASCII: 36
HTML: $
URL: %24
%
ASCII: 37
HTML: %
URL: %25
&
ASCII: 38
HTML: &amp;
URL: %26
'
ASCII: 39
HTML: '
URL: %27
(
ASCII: 40
HTML: (
URL: %28
)
ASCII: 41
HTML: )
URL: %29
*
ASCII: 42
HTML: *
URL: %2A
+
ASCII: 43
HTML: +
URL: %2B
,
ASCII: 44
HTML: ,
URL: %2C
-
ASCII: 45
HTML: -
URL: %2D
.
ASCII: 46
HTML: .
URL: %2E
/
ASCII: 47
HTML: /
URL: %2F
:
ASCII: 58
HTML: :
URL: %3A
;
ASCII: 59
HTML: ;
URL: %3B
<
ASCII: 60
HTML: &lt;
URL: %3C
=
ASCII: 61
HTML: =
URL: %3D
>
ASCII: 62
HTML: &gt;
URL: %3E
?
ASCII: 63
HTML: ?
URL: %3F
@
ASCII: 64
HTML: @
URL: %40
[
ASCII: 91
HTML: [
URL: %5B
\
ASCII: 92
HTML: \
URL: %5C
]
ASCII: 93
HTML: ]
URL: %5D
^
ASCII: 94
HTML: ^
URL: %5E
_
ASCII: 95
HTML: _
URL: %5F
`
ASCII: 96
HTML: `
URL: %60
{
ASCII: 123
HTML: {
URL: %7B
|
ASCII: 124
HTML: |
URL: %7C
}
ASCII: 125
HTML: }
URL: %7D
~
ASCII: 126
HTML: ~
URL: %7E

ASCII: 127
HTML: 
URL: %7F
ASCII: 128
HTML: &#8364;
URL: %80

ASCII: 129
HTML: &#129;
URL: %81
ASCII: 130
HTML: &#8218;
URL: %82
ƒ
ASCII: 131
HTML: &#402;
URL: %83
ASCII: 132
HTML: &#8222;
URL: %84
ASCII: 133
HTML: &#8230;
URL: %85
ASCII: 134
HTML: &#8224;
URL: %86
ASCII: 135
HTML: &#8225;
URL: %87
ˆ
ASCII: 136
HTML: &#710;
URL: %88
ASCII: 137
HTML: &#8240;
URL: %89
Š
ASCII: 138
HTML: &#352;
URL: %8A
ASCII: 139
HTML: &#8249;
URL: %8B
Œ
ASCII: 140
HTML: &#338;
URL: %8C

ASCII: 141
HTML: &#141;
URL: %8D
Ž
ASCII: 142
HTML: &#381;
URL: %8E

ASCII: 143
HTML: &#143;
URL: %8F

ASCII: 144
HTML: &#144;
URL: %90
ASCII: 145
HTML: &#8216;
URL: %91
ASCII: 146
HTML: &#8217;
URL: %92
ASCII: 147
HTML: &#8220;
URL: %93
ASCII: 148
HTML: &#8221;
URL: %94
ASCII: 149
HTML: &#8226;
URL: %95
ASCII: 150
HTML: &#8211;
URL: %96
ASCII: 151
HTML: &#8212;
URL: %97
˜
ASCII: 152
HTML: &#732;
URL: %98
ASCII: 153
HTML: &#8482;
URL: %99
š
ASCII: 154
HTML: &#353;
URL: %9A
ASCII: 155
HTML: &#8250;
URL: %9B
œ
ASCII: 156
HTML: &#339;
URL: %9C

ASCII: 157
HTML: &#157;
URL: %9D
ž
ASCII: 158
HTML: &#382;
URL: %9E
Ÿ
ASCII: 159
HTML: &#376;
URL: %9F
 
ASCII: 160
HTML: &#160;
URL: %A0
¡
ASCII: 161
HTML: &#161;
URL: %A1
¢
ASCII: 162
HTML: &#162;
URL: %A2
£
ASCII: 163
HTML: &#163;
URL: %A3
¤
ASCII: 164
HTML: &#164;
URL: %A4
¥
ASCII: 165
HTML: &#165;
URL: %A5
¦
ASCII: 166
HTML: &#166;
URL: %A6
§
ASCII: 167
HTML: &#167;
URL: %A7
¨
ASCII: 168
HTML: &#168;
URL: %A8
©
ASCII: 169
HTML: &#169;
URL: %A9
ª
ASCII: 170
HTML: &#170;
URL: %AA
«
ASCII: 171
HTML: &#171;
URL: %AB
¬
ASCII: 172
HTML: &#172;
URL: %AC
­
ASCII: 173
HTML: &#173;
URL: %AD
®
ASCII: 174
HTML: &#174;
URL: %AE
¯
ASCII: 175
HTML: &#175;
URL: %AF
°
ASCII: 176
HTML: &#176;
URL: %B0
±
ASCII: 177
HTML: &#177;
URL: %B1
²
ASCII: 178
HTML: &#178;
URL: %B2
³
ASCII: 179
HTML: &#179;
URL: %B3
´
ASCII: 180
HTML: &#180;
URL: %B4
µ
ASCII: 181
HTML: &#181;
URL: %B5
ASCII: 182
HTML: &#182;
URL: %B6
·
ASCII: 183
HTML: &#183;
URL: %B7
¸
ASCII: 184
HTML: &#184;
URL: %B8
¹
ASCII: 185
HTML: &#185;
URL: %B9
º
ASCII: 186
HTML: &#186;
URL: %BA
»
ASCII: 187
HTML: &#187;
URL: %BB
¼
ASCII: 188
HTML: &#188;
URL: %BC
½
ASCII: 189
HTML: &#189;
URL: %BD
¾
ASCII: 190
HTML: &#190;
URL: %BE
¿
ASCII: 191
HTML: &#191;
URL: %BF
À
ASCII: 192
HTML: &#192;
URL: %C0
Á
ASCII: 193
HTML: &#193;
URL: %C1
Â
ASCII: 194
HTML: &#194;
URL: %C2
Ã
ASCII: 195
HTML: &#195;
URL: %C3
Ä
ASCII: 196
HTML: &#196;
URL: %C4
Å
ASCII: 197
HTML: &#197;
URL: %C5
Æ
ASCII: 198
HTML: &#198;
URL: %C6
Ç
ASCII: 199
HTML: &#199;
URL: %C7
È
ASCII: 200
HTML: &#200;
URL: %C8
É
ASCII: 201
HTML: &#201;
URL: %C9
Ê
ASCII: 202
HTML: &#202;
URL: %CA
Ë
ASCII: 203
HTML: &#203;
URL: %CB
Ì
ASCII: 204
HTML: &#204;
URL: %CC
Í
ASCII: 205
HTML: &#205;
URL: %CD
Î
ASCII: 206
HTML: &#206;
URL: %CE
Ï
ASCII: 207
HTML: &#207;
URL: %CF
Ð
ASCII: 208
HTML: &#208;
URL: %D0
Ñ
ASCII: 209
HTML: &#209;
URL: %D1
Ò
ASCII: 210
HTML: &#210;
URL: %D2
Ó
ASCII: 211
HTML: &#211;
URL: %D3
Ô
ASCII: 212
HTML: &#212;
URL: %D4
Õ
ASCII: 213
HTML: &#213;
URL: %D5
Ö
ASCII: 214
HTML: &#214;
URL: %D6
×
ASCII: 215
HTML: &#215;
URL: %D7
Ø
ASCII: 216
HTML: &#216;
URL: %D8
Ù
ASCII: 217
HTML: &#217;
URL: %D9
Ú
ASCII: 218
HTML: &#218;
URL: %DA
Û
ASCII: 219
HTML: &#219;
URL: %DB
Ü
ASCII: 220
HTML: &#220;
URL: %DC
Ý
ASCII: 221
HTML: &#221;
URL: %DD
Þ
ASCII: 222
HTML: &#222;
URL: %DE
ß
ASCII: 223
HTML: &#223;
URL: %DF
à
ASCII: 224
HTML: &#224;
URL: %E0
á
ASCII: 225
HTML: &#225;
URL: %E1
â
ASCII: 226
HTML: &#226;
URL: %E2
ã
ASCII: 227
HTML: &#227;
URL: %E3
ä
ASCII: 228
HTML: &#228;
URL: %E4
å
ASCII: 229
HTML: &#229;
URL: %E5
æ
ASCII: 230
HTML: &#230;
URL: %E6
ç
ASCII: 231
HTML: &#231;
URL: %E7
è
ASCII: 232
HTML: &#232;
URL: %E8
é
ASCII: 233
HTML: &#233;
URL: %E9
ê
ASCII: 234
HTML: &#234;
URL: %EA
ë
ASCII: 235
HTML: &#235;
URL: %EB
ì
ASCII: 236
HTML: &#236;
URL: %EC
í
ASCII: 237
HTML: &#237;
URL: %ED
î
ASCII: 238
HTML: &#238;
URL: %EE
ï
ASCII: 239
HTML: &#239;
URL: %EF
ð
ASCII: 240
HTML: &#240;
URL: %F0
ñ
ASCII: 241
HTML: &#241;
URL: %F1
ò
ASCII: 242
HTML: &#242;
URL: %F2
ó
ASCII: 243
HTML: &#243;
URL: %F3
ô
ASCII: 244
HTML: &#244;
URL: %F4
õ
ASCII: 245
HTML: &#245;
URL: %F5
ö
ASCII: 246
HTML: &#246;
URL: %F6
÷
ASCII: 247
HTML: &#247;
URL: %F7
ø
ASCII: 248
HTML: &#248;
URL: %F8
ù
ASCII: 249
HTML: &#249;
URL: %F9
ú
ASCII: 250
HTML: &#250;
URL: %FA
û
ASCII: 251
HTML: &#251;
URL: %FB
ü
ASCII: 252
HTML: &#252;
URL: %FC
ý
ASCII: 253
HTML: &#253;
URL: %FD
þ
ASCII: 254
HTML: &#254;
URL: %FE
ÿ
ASCII: 255
HTML: &#255;
URL: %FF

 

 

Reference:
打法语 http://www.dadeyu.com/

Special Charactor http://web.forret.com/tools/charmap.asp?show=ascii/

iso-8859-1 http://zh.wikipedia.org/wiki/ISO/IEC_8859

 

posted on 2012-07-17 21:36  Carrey Mu  阅读(1381)  评论(0编辑  收藏  举报