| 86 | |
| 87 | |
| 88 | void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) |
| 89 | { |
| 90 | const unsigned long BYTE_MASK = 0xBF; |
| 91 | const unsigned long BYTE_MARK = 0x80; |
| 92 | const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; |
| 93 | |
| 94 | if (input < 0x80) |
| 95 | *length = 1; |
| 96 | else if ( input < 0x800 ) |
| 97 | *length = 2; |
| 98 | else if ( input < 0x10000 ) |
| 99 | *length = 3; |
| 100 | else if ( input < 0x200000 ) |
| 101 | *length = 4; |
| 102 | else |
| 103 | { *length = 0; return; } // This code won't covert this correctly anyway. |
| 104 | |
| 105 | output += *length; |
| 106 | |
| 107 | // Scary scary fall throughs. |
| 108 | switch (*length) |
| 109 | { |
| 110 | case 4: |
| 111 | --output; |
| 112 | *output = (char)((input | BYTE_MARK) & BYTE_MASK); |
| 113 | input >>= 6; |
| 114 | case 3: |
| 115 | --output; |
| 116 | *output = (char)((input | BYTE_MARK) & BYTE_MASK); |
| 117 | input >>= 6; |
| 118 | case 2: |
| 119 | --output; |
| 120 | *output = (char)((input | BYTE_MARK) & BYTE_MASK); |
| 121 | input >>= 6; |
| 122 | case 1: |
| 123 | --output; |
| 124 | *output = (char)(input | FIRST_BYTE_MARK[*length]); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | |
| 129 | /*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) |
nothing calls this directly
no outgoing calls
no test coverage detected