• Chris Bracken's avatar
    Decode syslog-encoded iOS logs (#14075) · 6a42ed3f
    Chris Bracken authored
    Apple encodes syslog entries using a 7-bit encoding where input UTF-8 bytes
    are encoded as follows:
    1. 0x00 to 0x19: non-printing range. Some ignored, some encoded as <...>.
    2. 0x20 to 0x7f: as-is, with the exception of 0x5c (backslash).
    3. 0x5c (backslash): octal representation \134.
    4. 0x80 to 0x9f: \M^x (using control-character notation for range 0x00 to 0x40).
    5. 0xa0: octal representation \240.
    6. 0xa1 to 0xf7: \M-x (where x is the input byte stripped of its high-order bit).
    7. 0xf8 to 0xff: unused in 4-byte UTF-8.
    
    As there doesn't appear to be a system tool to decode these strings, we
    implement here in Dart. If we're unable to decode a string (e.g.
    decoding results in an invalid UTF-8 string), we fall back to emitting
    the log line as-is.
    6a42ed3f
devices_test.dart 5.52 KB