Differences From Artifact [b1b921ad96]:
- File src/OFStdIOStream.m — part of check-in [0a001bfd7b] at 2016-02-28 15:31:18 on branch trunk — OFStdIOStream: Set codepage to UTF-8 on Windows (user: js, size: 4555) [annotate] [blame] [check-ins using]
To Artifact [e2adf5fa8a]:
- File
src/OFStdIOStream.m
— part of check-in
[3e1b6bccbc]
at
2016-03-12 20:28:31
on branch trunk
— Properly handle UTF-8 in Win32 console
The previous way was to set the codepage to UTF-8, however, this does
not work properly on some versions of Windows.Instead, this catches reads / writes on of_std* on the lowlevel,
interprets it as UTF-8, converts it to / from UTF-16 and then uses
ReadConsoleW() / WriteConsoleW().Surrogates being cut in the middle is not properly handled yet, this
will be implemented in a follow up commit. (user: js, size: 4066) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 | # undef __USE_XOPEN #endif #include <errno.h> #include <unistd.h> #import "OFStdIOStream.h" #import "OFDate.h" #import "OFApplication.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" | > < < < < < < < < < < < < < < < < < < < < | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | # undef __USE_XOPEN #endif #include <errno.h> #include <unistd.h> #import "OFStdIOStream.h" #import "OFStdIOStream+Private.h" #import "OFDate.h" #import "OFApplication.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" OFStdIOStream *of_stdin = nil; OFStdIOStream *of_stdout = nil; OFStdIOStream *of_stderr = nil; void of_log(OFConstantString *format, ...) { void *pool = objc_autoreleasePoolPush(); OFDate *date; OFString *dateString, *me, *msg; va_list arguments; |
︙ | ︙ | |||
77 78 79 80 81 82 83 84 85 86 87 88 89 | [of_stderr writeFormat: @"[%@.%03d %@(%d)] %@\n", dateString, [date microsecond] / 1000, me, getpid(), msg]; objc_autoreleasePoolPop(pool); } @implementation OFStdIOStream + (void)load { of_stdin = [[OFStdIOStream alloc] OF_initWithFileDescriptor: 0]; of_stdout = [[OFStdIOStream alloc] OF_initWithFileDescriptor: 1]; of_stderr = [[OFStdIOStream alloc] OF_initWithFileDescriptor: 2]; } | > < < < < < < < < < < < | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | [of_stderr writeFormat: @"[%@.%03d %@(%d)] %@\n", dateString, [date microsecond] / 1000, me, getpid(), msg]; objc_autoreleasePoolPop(pool); } @implementation OFStdIOStream #ifndef OF_WINDOWS + (void)load { of_stdin = [[OFStdIOStream alloc] OF_initWithFileDescriptor: 0]; of_stdout = [[OFStdIOStream alloc] OF_initWithFileDescriptor: 1]; of_stderr = [[OFStdIOStream alloc] OF_initWithFileDescriptor: 2]; } #endif - init { OF_INVALID_INIT_METHOD } |
︙ | ︙ |