Проблема с кодировкой

Raids

Client
Регистрация
12.09.2017
Сообщения
41
Благодарностей
19
Баллы
8
отсылаю POST запросом сообщение в виде URLEncode "привет", получатель видит кракозябры "привет"
У меня такой код получается:

Код:
input_message=%d0%bf%d1%80%d0%b8%d0%b2%d0%b5%d1%82
отловил в фидлере запрос:

Код:
input_message=%EF%F0%E8%E2%E5%F2
Как я понял надо перекодировать из UTF8 в windows-1251 потом уже URLEncode, но код:

Код:
byte[] utfBytes = Encoding.UTF8.GetBytes("привет");
byte[] koi8rBytes = Encoding.Convert(Encoding.UTF8, Encoding.GetEncoding("windows-1251"), utfBytes);
var koi8rString = Encoding.GetEncoding("koi8-r").GetString(koi8rBytes);
return System.Web.HttpUtility.UrlEncode(koi8rString);
не решает проблему.

Помогите пожалуйста, всю голову сломал уже.
 

Raids

Client
Регистрация
12.09.2017
Сообщения
41
Благодарностей
19
Баллы
8
Путем научного тыка сделал костыль:

Код:
string text = project.Variables["message"].Value;
text = text.Replace("+","%2B");
text = text.Replace("%","%25");
text = text.Replace("&","%26");
text = text.Replace("Ё","%A8");
text = text.Replace("ё","%B8");
text = text.Replace("А","%C0");
text = text.Replace("Б","%C1");
text = text.Replace("В","%C2");
text = text.Replace("Г","%C3");
text = text.Replace("Д","%C4");
text = text.Replace("Е","%C5");
text = text.Replace("Ж","%C6");
text = text.Replace("З","%C7");
text = text.Replace("И","%C8");
text = text.Replace("Й","%C9");
text = text.Replace("К","%CA");
text = text.Replace("Л","%CB");
text = text.Replace("М","%CC");
text = text.Replace("Н","%CD");
text = text.Replace("О","%CE");
text = text.Replace("П","%CF");
text = text.Replace("Р","%D0");
text = text.Replace("С","%D1");
text = text.Replace("Т","%D2");
text = text.Replace("У","%D3");
text = text.Replace("Ф","%D4");
text = text.Replace("Х","%D5");
text = text.Replace("Ц","%D6");
text = text.Replace("Ч","%D7");
text = text.Replace("Ш","%D8");
text = text.Replace("Щ","%D9");
text = text.Replace("Ъ","%DA");
text = text.Replace("Ы","%DB");
text = text.Replace("Ь","%DC");
text = text.Replace("Э","%DD");
text = text.Replace("Ю","%DE");
text = text.Replace("Я","%DF");
text = text.Replace("а","%E0");
text = text.Replace("б","%E1");
text = text.Replace("в","%E2");
text = text.Replace("г","%E3");
text = text.Replace("д","%E4");
text = text.Replace("е","%E5");
text = text.Replace("ж","%E6");
text = text.Replace("з","%E7");
text = text.Replace("и","%E8");
text = text.Replace("й","%E9");
text = text.Replace("к","%EA");
text = text.Replace("л","%EB");
text = text.Replace("м","%EC");
text = text.Replace("н","%ED");
text = text.Replace("о","%EE");
text = text.Replace("п","%EF");
text = text.Replace("р","%F0");
text = text.Replace("с","%F1");
text = text.Replace("т","%F2");
text = text.Replace("у","%F3");
text = text.Replace("ф","%F4");
text = text.Replace("х","%F5");
text = text.Replace("ц","%F6");
text = text.Replace("ч","%F7");
text = text.Replace("ш","%F8");
text = text.Replace("щ","%F9");
text = text.Replace("ъ","%FA");
text = text.Replace("ы","%FB");
text = text.Replace("ь","%FC");
text = text.Replace("э","%FD");
text = text.Replace("ю","%FE");
text = text.Replace("я","%FF");
text = text.Replace("+","%2B");
text = text.Replace("%","%25");
text = text.Replace("&","%26");
text = text.Replace("Ё","%A8");
text = text.Replace("ё","%B8");
text = text.Replace("А","%C0");
text = text.Replace("Б","%C1");
text = text.Replace("В","%C2");
text = text.Replace("Г","%C3");
text = text.Replace("Д","%C4");
text = text.Replace("Е","%C5");
text = text.Replace("Ж","%C6");
text = text.Replace("З","%C7");
text = text.Replace("И","%C8");
text = text.Replace("Й","%C9");
text = text.Replace("К","%CA");
text = text.Replace("Л","%CB");
text = text.Replace("М","%CC");
text = text.Replace("Н","%CD");
text = text.Replace("О","%CE");
text = text.Replace("П","%CF");
text = text.Replace("Р","%D0");
text = text.Replace("С","%D1");
text = text.Replace("Т","%D2");
text = text.Replace("У","%D3");
text = text.Replace("Ф","%D4");
text = text.Replace("Х","%D5");
text = text.Replace("Ц","%D6");
text = text.Replace("Ч","%D7");
text = text.Replace("Ш","%D8");
text = text.Replace("Щ","%D9");
text = text.Replace("Ъ","%DA");
text = text.Replace("Ы","%DB");
text = text.Replace("Ь","%DC");
text = text.Replace("Э","%DD");
text = text.Replace("Ю","%DE");
text = text.Replace("Я","%DF");
text = text.Replace("а","%E0");
text = text.Replace("б","%E1");
text = text.Replace("в","%E2");
text = text.Replace("г","%E3");
text = text.Replace("д","%E4");
text = text.Replace("е","%E5");
text = text.Replace("ж","%E6");
text = text.Replace("з","%E7");
text = text.Replace("и","%E8");
text = text.Replace("й","%E9");
text = text.Replace("к","%EA");
text = text.Replace("л","%EB");
text = text.Replace("м","%EC");
text = text.Replace("н","%ED");
text = text.Replace("о","%EE");
text = text.Replace("п","%EF");
text = text.Replace("р","%F0");
text = text.Replace("с","%F1");
text = text.Replace("т","%F2");
text = text.Replace("у","%F3");
text = text.Replace("ф","%F4");
text = text.Replace("х","%F5");
text = text.Replace("ц","%F6");
text = text.Replace("ч","%F7");
text = text.Replace("ш","%F8");
text = text.Replace("щ","%F9");
text = text.Replace("ъ","%FA");
text = text.Replace("ы","%FB");
text = text.Replace("ь","%FC");
text = text.Replace("э","%FD");
text = text.Replace("ю","%FE");
text = text.Replace("я","%FF");
может кто тоже столкнется
 

doc

Client
Регистрация
30.03.2012
Сообщения
8 607
Благодарностей
4 598
Баллы
113
Путем научного тыка сделал костыль:

Код:
string text = project.Variables["message"].Value;
text = text.Replace("+","%2B");
text = text.Replace("%","%25");
text = text.Replace("&","%26");
text = text.Replace("Ё","%A8");
text = text.Replace("ё","%B8");
text = text.Replace("А","%C0");
text = text.Replace("Б","%C1");
text = text.Replace("В","%C2");
text = text.Replace("Г","%C3");
text = text.Replace("Д","%C4");
text = text.Replace("Е","%C5");
text = text.Replace("Ж","%C6");
text = text.Replace("З","%C7");
text = text.Replace("И","%C8");
text = text.Replace("Й","%C9");
text = text.Replace("К","%CA");
text = text.Replace("Л","%CB");
text = text.Replace("М","%CC");
text = text.Replace("Н","%CD");
text = text.Replace("О","%CE");
text = text.Replace("П","%CF");
text = text.Replace("Р","%D0");
text = text.Replace("С","%D1");
text = text.Replace("Т","%D2");
text = text.Replace("У","%D3");
text = text.Replace("Ф","%D4");
text = text.Replace("Х","%D5");
text = text.Replace("Ц","%D6");
text = text.Replace("Ч","%D7");
text = text.Replace("Ш","%D8");
text = text.Replace("Щ","%D9");
text = text.Replace("Ъ","%DA");
text = text.Replace("Ы","%DB");
text = text.Replace("Ь","%DC");
text = text.Replace("Э","%DD");
text = text.Replace("Ю","%DE");
text = text.Replace("Я","%DF");
text = text.Replace("а","%E0");
text = text.Replace("б","%E1");
text = text.Replace("в","%E2");
text = text.Replace("г","%E3");
text = text.Replace("д","%E4");
text = text.Replace("е","%E5");
text = text.Replace("ж","%E6");
text = text.Replace("з","%E7");
text = text.Replace("и","%E8");
text = text.Replace("й","%E9");
text = text.Replace("к","%EA");
text = text.Replace("л","%EB");
text = text.Replace("м","%EC");
text = text.Replace("н","%ED");
text = text.Replace("о","%EE");
text = text.Replace("п","%EF");
text = text.Replace("р","%F0");
text = text.Replace("с","%F1");
text = text.Replace("т","%F2");
text = text.Replace("у","%F3");
text = text.Replace("ф","%F4");
text = text.Replace("х","%F5");
text = text.Replace("ц","%F6");
text = text.Replace("ч","%F7");
text = text.Replace("ш","%F8");
text = text.Replace("щ","%F9");
text = text.Replace("ъ","%FA");
text = text.Replace("ы","%FB");
text = text.Replace("ь","%FC");
text = text.Replace("э","%FD");
text = text.Replace("ю","%FE");
text = text.Replace("я","%FF");
text = text.Replace("+","%2B");
text = text.Replace("%","%25");
text = text.Replace("&","%26");
text = text.Replace("Ё","%A8");
text = text.Replace("ё","%B8");
text = text.Replace("А","%C0");
text = text.Replace("Б","%C1");
text = text.Replace("В","%C2");
text = text.Replace("Г","%C3");
text = text.Replace("Д","%C4");
text = text.Replace("Е","%C5");
text = text.Replace("Ж","%C6");
text = text.Replace("З","%C7");
text = text.Replace("И","%C8");
text = text.Replace("Й","%C9");
text = text.Replace("К","%CA");
text = text.Replace("Л","%CB");
text = text.Replace("М","%CC");
text = text.Replace("Н","%CD");
text = text.Replace("О","%CE");
text = text.Replace("П","%CF");
text = text.Replace("Р","%D0");
text = text.Replace("С","%D1");
text = text.Replace("Т","%D2");
text = text.Replace("У","%D3");
text = text.Replace("Ф","%D4");
text = text.Replace("Х","%D5");
text = text.Replace("Ц","%D6");
text = text.Replace("Ч","%D7");
text = text.Replace("Ш","%D8");
text = text.Replace("Щ","%D9");
text = text.Replace("Ъ","%DA");
text = text.Replace("Ы","%DB");
text = text.Replace("Ь","%DC");
text = text.Replace("Э","%DD");
text = text.Replace("Ю","%DE");
text = text.Replace("Я","%DF");
text = text.Replace("а","%E0");
text = text.Replace("б","%E1");
text = text.Replace("в","%E2");
text = text.Replace("г","%E3");
text = text.Replace("д","%E4");
text = text.Replace("е","%E5");
text = text.Replace("ж","%E6");
text = text.Replace("з","%E7");
text = text.Replace("и","%E8");
text = text.Replace("й","%E9");
text = text.Replace("к","%EA");
text = text.Replace("л","%EB");
text = text.Replace("м","%EC");
text = text.Replace("н","%ED");
text = text.Replace("о","%EE");
text = text.Replace("п","%EF");
text = text.Replace("р","%F0");
text = text.Replace("с","%F1");
text = text.Replace("т","%F2");
text = text.Replace("у","%F3");
text = text.Replace("ф","%F4");
text = text.Replace("х","%F5");
text = text.Replace("ц","%F6");
text = text.Replace("ч","%F7");
text = text.Replace("ш","%F8");
text = text.Replace("щ","%F9");
text = text.Replace("ъ","%FA");
text = text.Replace("ы","%FB");
text = text.Replace("ь","%FC");
text = text.Replace("э","%FD");
text = text.Replace("ю","%FE");
text = text.Replace("я","%FF");
может кто тоже столкнется
Код:
string s = "привет";
return System.Web.HttpUtility.UrlEncode(s, Encoding.GetEncoding("windows-1251"));
Нужно добавить ссылку bp GAC на System.Web.dll
 
  • Спасибо
Реакции: Raids

Raids

Client
Регистрация
12.09.2017
Сообщения
41
Благодарностей
19
Баллы
8
Код:
string s = "привет";
return System.Web.HttpUtility.UrlEncode(s, Encoding.GetEncoding("windows-1251"));
Нужно добавить ссылку bp GAC на System.Web.dll
Работает!
Именно этого мне не хватало всю ночь, спасибо.
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)