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