Overview
Comment: | Add of_string_unicode_to_utf8 which converts unicode to UTF-8. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
de937a62e412eabc964911d34554a779 |
User & Date: | js on 2009-07-14 21:22:42 |
Other Links: | manifest | tags |
Context
2009-07-14
| ||
21:58 | Also parse &#NNNN; and &#xHHHH; in -[stringByXMLUnescaping]. check-in: a80e9b948d user: js tags: trunk | |
21:22 | Add of_string_unicode_to_utf8 which converts unicode to UTF-8. check-in: de937a62e4 user: js tags: trunk | |
18:57 | Add OFString (OFXMLUnescaping) category and API for OFXMLParser. check-in: d8684fc232 user: js tags: trunk | |
Changes
Modified src/OFString.h from [dedea52274] to [42972211ab].
︙ | ︙ | |||
11 12 13 14 15 16 17 | #include <stdio.h> #include <stdarg.h> #import "OFObject.h" #import "OFArray.h" | | > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include <stdio.h> #include <stdarg.h> #import "OFObject.h" #import "OFArray.h" extern int of_string_check_utf8(const char*, size_t); extern size_t of_string_unicode_to_utf8(uint32_t, uint8_t*); /** * A class for managing strings. */ @interface OFString: OFObject <OFCopying, OFMutableCopying> { char *string; |
︙ | ︙ |
Modified src/OFString.m from [c51d9e7bc3] to [2bac621bba].
︙ | ︙ | |||
100 101 102 103 104 105 106 107 108 109 110 111 112 113 | i += 3; } madvise((void*)str, len, MADV_NORMAL); return utf8; } @implementation OFString + string { return [[[self alloc] init] autorelease]; } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | i += 3; } madvise((void*)str, len, MADV_NORMAL); return utf8; } size_t of_string_unicode_to_utf8(uint32_t c, uint8_t *buf) { if (c < 0x80) { buf[0] = c; return 1; } if (c < 0x800) { buf[0] = 0xC0 | (c >> 6); buf[1] = 0x80 | (c & 0x3F); return 2; } if (c < 0x10000) { buf[0] = 0xE0 | (c >> 12); buf[1] = 0x80 | (c >> 6 & 0x3F); buf[2] = 0x80 | (c & 0x3F); return 3; } if (c < 0x110000) { buf[0] = 0xF0 | (c >> 18); buf[1] = 0x80 | (c >> 12 & 0x3F); buf[2] = 0x80 | (c >> 6 & 0x3F); buf[3] = 0x80 | (c & 0x3F); return 4; } return 0; } @implementation OFString + string { return [[[self alloc] init] autorelease]; } |
︙ | ︙ |