diff options
-rw-r--r-- | MLKStringInputStream.m | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/MLKStringInputStream.m b/MLKStringInputStream.m index c8d7a38..0701d79 100644 --- a/MLKStringInputStream.m +++ b/MLKStringInputStream.m @@ -33,14 +33,21 @@ -(MLKStringInputStream *) initWithString:(NSString *)string { + // We used to use NSUnicodeStringEncoding here, but Mac OS X has + // the strange habit of using a byte-order mark in internal string + // representations. This complicates matters: -readCharNoCache + // will correctly read the first character of a string, since the + // beginning of the string includes the BOM, but subsequent + // characters may or may not be read correctly depending on the + // host's default endianness. MLKStreamStream *binstream = LAUTORELEASE ([[MLKStreamStream alloc] initWithInputStream: [NSInputStream inputStreamWithData: [string dataUsingEncoding: - NSUnicodeStringEncoding]]]); + NSUTF8StringEncoding]]]); self = (id) [super initWithBinaryStream:binstream - encoding:NSUnicodeStringEncoding]; + encoding:NSUTF8StringEncoding]; return self; } |