1

Вопрос по iphone – NSStream, UTF8String & NSString… грязное преобразование

Я создаю пакет данных для отправки по NSStream на сервер. Я пытаюсь разделить два фрагмента данных с помощью a & apos; & # xA7; 'apos; (код ASCII 167). Так устроен сервер, поэтому мне нужно постараться не выходить за эти рамки ...

unichar asciiChar = 167;  //yields @"§"
[self setSepString:[NSString stringWithCharacters:&asciiChar length:1]]; 

sendData=[NSString stringWithFormat:@"USER User%@Pass", sepString];

NSLog(sendData);

const uint8_t *rawString=(const uint8_t *)[sendData UTF8String];

[oStream write:rawString maxLength:[sendData length]];  

So the final outcome should look like this.. and it does when sendData is first constructed:

USER User§Pass 

however, when it is received on the server side, it looks like this:

//not a direct copy and paste. The 'mystery character' may not be exact
USER UserˤPas

...the seperator string has become two in length, and the last letter is getting cropped from the command. I believe this to be cause by the UTF8 conversion.

Кто-нибудь может пролить свет на это для меня?

Любая помощь будет принята с благодарностью!

  • Error: User Rate Limit Exceeded

    от Dutchie432
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от Dutchie432
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от user102008
  • 1

    Error: User Rate Limit Exceeded

    167

    Construct the uint8_t* byte array using at least two different NSString objects plus the 167 code. This will be necessary if the username or password can possibly contain non-ascii characters. Use the NSString method getBytes:maxLength:usedLength:encoding:options:range:remainingRange and set encoding to NSASCIIStringEncoding. If you do this you must validate elsewhere that your username and password is us-ascii only. Use the NSString method getCString. However, that's been deprecated because you cannot specify the encoding you want.

  • 6

    Error: User Rate Limit Exceeded

    NSString -dataUsingEncoding:.