Этот баннер — требование Роскомнадзора для исполнения 152 ФЗ.
«На сайте осуществляется обработка файлов cookie, необходимых для работы сайта, а также для анализа использования сайта и улучшения предоставляемых сервисов с использованием метрической программы Яндекс.Метрика. Продолжая использовать сайт, вы даёте согласие с использованием данных технологий».
Политика конфиденциальности
|
|
|
Tcpclient: получение ответа от сервера и русские буквы
|
|||
|---|---|---|---|
|
#18+
Есть вот такой код. Пытаюсь получить список папок на почтовом сервере посылкой команды "LIST". private string SendToServer(string str) { string sResponse=""; Stream stm = tcpclnt.GetStream(); ASCIIEncoding asen= new ASCIIEncoding(); byte[] ba=asen.GetBytes(str); stm.Write(ba,0,ba.Length); byte[] bb=new byte[4096]; int k=stm.Read(bb,0,4096); for (int i=0;i<k;i++) sResponse += Convert.ToChar(bb[i]).ToString(); return sResponse; } Проблема заключается в том, что если в названии папок имеются русские буквы, то они отображаются не корректно. Пытался играться с кодировкой для буфера bb , но пока не вышло. Подскажите что делать? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.10.2006, 13:48 |
|
||
|
Tcpclient: получение ответа от сервера и русские буквы
|
|||
|---|---|---|---|
|
#18+
Ты знаешь в какой кодировке тебе буквы русские передают? можно попробовать например так: byte[] bb = new byte[4096]; string strResult = System.Text.Encoding.GetEncoding(1251).GetString(bb, 0, bb.Length); ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.10.2006, 14:44 |
|
||
|
Tcpclient: получение ответа от сервера и русские буквы
|
|||
|---|---|---|---|
|
#18+
Ты знаешь в какой кодировке тебе буквы русские передают? можно попробовать например так: byte[] bb = new byte[4096]; string strResult = System.Text.Encoding.GetEncoding(1251).GetString(bb, 0, bb.Length); Нет, такой вариант тоже не работает. Если поможет, то вот строка которая получается в ответ на ? LIST "" * : "* LIST (\\HasNoChildren) \"/\" INBOX\r\n* LIST (\\HasNoChildren) \"/\" \"sent\"\r\n* LIST (\\HasNoChildren) \"/\" \"drafts\"\r\n* LIST (\\HasNoChildren) \"/\" \"trash\"\r\n* LIST (\\HasNoChildren) \"/\" \"&BCEEPgQ8BD0EOARCBDUEOwRMBD0ESwQ1-\"\r\n? OK List completed.\0" Так вот вместо строки: "&BCEEPgQ8BD0EOARCBDUEOwRMBD0ESwQ1-" должно быть "Сомнительные". Тестирую на сервере Mail.ru/ ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.10.2006, 16:25 |
|
||
|
Tcpclient: получение ответа от сервера и русские буквы
|
|||
|---|---|---|---|
|
#18+
... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.10.2006, 16:44 |
|
||
|
Tcpclient: получение ответа от сервера и русские буквы
|
|||
|---|---|---|---|
|
#18+
Реально в какой кодировке тебе ответы шлются сначала узнай или методом научного тыка тада переберай string strResult = System.Text. XXXEncoding. GetString(bb, 0, bb.Length); и должно получится ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.10.2006, 16:50 |
|
||
|
Tcpclient: получение ответа от сервера и русские буквы
|
|||
|---|---|---|---|
|
#18+
Понятно ж в какой кодировке вроде ... авторABSTRACT IMAP mailbox names are encoded in a modified UTF7 when names contains international characters outside of the printable ASCII range. The modified UTF-7 encoding is defined in RFC2060 (section 5.1.3). There is another CPAN module with same purpose, Unicode::IMAPUtf7. However, it works correctly only with strings, which encoded form does not contain plus sign. For example, the Cyrillic string \x{043f}\x{0440}\x{0435}\x{0434}\x{043b}\x{043e}\x{0433} is represented in UTF-7 as +BD8EQAQ1BDQEOwQ+BDM- Note the second plus sign 4 characters before the end. Unicode::IMAPUtf7 encodes the above string as +BD8EQAQ1BDQEOwQ&BDM- which is not valid modified UTF-7 (the ampersand and the plus are swapped). The problem is solved by the current module, which is slightly modified Encode::Unicode::UTF7 and has nothing common with Unicode::IMAPUtf7. RFC2060 - section 5.1.3 - Mailbox International Naming Convention By convention, international mailbox names are specified using a modified version of the UTF-7 encoding described in [UTF-7]. The purpose of these modifications is to correct the following problems with UTF-7: 1) UTF-7 uses the "+" character for shifting; this conflicts with the common use of "+" in mailbox names, in particular USENET newsgroup names. 2) UTF-7's encoding is BASE64 which uses the "/" character; this conflicts with the use of "/" as a popular hierarchy delimiter. 3) UTF-7 prohibits the unencoded usage of "\"; this conflicts with the use of "\" as a popular hierarchy delimiter. 4) UTF-7 prohibits the unencoded usage of "~"; this conflicts with the use of "~" in some servers as a home directory indicator. 5) UTF-7 permits multiple alternate forms to represent the same string; in particular, printable US-ASCII chararacters can be represented in encoded form. In modified UTF-7, printable US-ASCII characters except for "&" represent themselves; that is, characters with octet values 0x20-0x25 and 0x27-0x7e. The character "&" (0x26) is represented by the two- octet sequence "&-". All other characters (octet values 0x00-0x1f, 0x7f-0xff, and all Unicode 16-bit octets) are represented in modified BASE64, with a further modification from [UTF-7] that "," is used instead of "/". Modified BASE64 MUST NOT be used to represent any printing US-ASCII character which can represent itself. "&" is used to shift to modified BASE64 and "-" to shift back to US- ASCII. All names start in US-ASCII, and MUST end in US-ASCII (that is, a name that ends with a Unicode 16-bit octet MUST end with a "- "). For example, here is a mailbox name which mixes English, Japanese, and Chinese text: ~peter/mail/&ZeVnLIqe-/&U,BTFw- ------------------------------- www.free-lancer.ru ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.10.2006, 16:53 |
|
||
|
Tcpclient: получение ответа от сервера и русские буквы
|
|||
|---|---|---|---|
|
#18+
? = Encoding.ASCII.GetString(Encoding.UTF7.GetBytes("Сомнительные")); ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.10.2006, 17:02 |
|
||
|
Tcpclient: получение ответа от сервера и русские буквы
|
|||
|---|---|---|---|
|
#18+
? = Encoding.ASCII.GetString(Encoding.UTF7.GetBytes("Сомнительные")); Почти так. Для этого варианта получается строка: +BCEEPgQ8BD0EOARCBDUEOwRMBD0ESwQ1- А сервер возвращает &BCEEPgQ8BD0EOARCBDUEOwRMBD0ESwQ1- ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.10.2006, 17:29 |
|
||
|
Tcpclient: получение ответа от сервера и русские буквы
|
|||
|---|---|---|---|
|
#18+
И если заменить вручную: & на +, то все встает на места. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.10.2006, 17:34 |
|
||
|
Tcpclient: получение ответа от сервера и русские буквы
|
|||
|---|---|---|---|
|
#18+
Реально в какой кодировке тебе ответы шлются сначала узнай или методом научного тыка тада переберай string strResult = System.Text.[q]XXXEncoding.[/q]GetString(bb, 0, bb.Length); и должно получится Очень похоже на кодировку UTF7, но модифицированную. Символы + и / меняются на & и , . ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 11.10.2006, 10:11 |
|
||
|
|

start [/forum/topic.php?fid=18&fpage=858&tid=1388714]: |
0ms |
get settings: |
10ms |
get forum list: |
17ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
27ms |
get topic data: |
11ms |
get forum data: |
3ms |
get page messages: |
47ms |
get tp. blocked users: |
1ms |
| others: | 253ms |
| total: | 375ms |

| 0 / 0 |
