Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > .NET для новичков > Не могу понять что за кодировка?


Автор: DenWPF 23.3.2010, 18:38
(ïðè æåëàíèè)

Автор: Fortnox 23.3.2010, 19:31
CP1252

Автор: DenWPF 23.3.2010, 20:15
а как её перевести? не могу не чего найти=(

Автор: DenWPF 24.3.2010, 08:22
пытаюсь так

Код

            string unicodeString = "This string contains the unicode character Pi";

            // Create two different encodings.
            Encoding ascii = Encoding.UTF8;
            Encoding unicode = Encoding.GetEncoding(1252);

            // Convert the string into a byte[].
            byte[] unicodeBytes = unicode.GetBytes(unicodeString);

            // Perform the conversion from one encoding to the other.
            byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes);

            // Convert the new byte[] into a char[] and then into a string.
            // This is a slightly different approach to converting to illustrate
            // the use of GetCharCount/GetChars.
            char[] asciiChars = new char[ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)];
            ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
            string asciiString = new string(asciiChars);

переменные я там уже как угодно меня....
чистого cp1252 не нашел..

Автор: Fortnox 24.3.2010, 11:47
DenWPF, вот так:
Код

            byte[] bytesStr = Encoding.GetEncoding(1252).GetBytes(inputStr);
            string result = Encoding.GetEncoding(1251).GetString(bytesStr);


Автор: DenWPF 24.3.2010, 13:06
Hea

Автор: Fortnox 24.3.2010, 14:36
Простой пример - все работает.

Автор: DenWPF 25.3.2010, 08:59
значит не то =(

ну смотрите браузер передает русскую фразу "(при желании)" в таком виде %28%EF%F0%E8+%E6%E5%EB%E0%ED%E8%E8%29


Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)