@@ -63,10 +63,15 @@ selector: _cmd]; } - (OFString*)readLine { + return [self readLineWithEncoding: OF_STRING_ENCODING_UTF_8]; +} + +- (OFString*)readLineWithEncoding: (enum of_string_encoding)encoding +{ size_t i, len; char *ret_c, *tmp, *tmp2; OFString *ret; /* Look if there's a line or \0 in our cache */ @@ -73,10 +78,11 @@ if (cache != NULL) { for (i = 0; i < cache_len; i++) { if (OF_UNLIKELY(cache[i] == '\n' || cache[i] == '\0')) { ret = [OFString stringWithCString: cache + encoding: encoding length: i]; tmp = [self allocMemoryWithSize: cache_len - i - 1]; memcpy(tmp, cache + i + 1, cache_len - i - 1); @@ -99,10 +105,11 @@ if (cache == NULL) return nil; ret = [OFString stringWithCString: cache + encoding: encoding length: cache_len]; [self freeMemory: cache]; cache = NULL; cache_len = 0; @@ -158,11 +165,12 @@ } [self freeMemory: tmp]; @try { ret = [OFString - stringWithCString: ret_c]; + stringWithCString: ret_c + encoding: encoding]; } @finally { [self freeMemory: ret_c]; } return ret; }