| 586 | // Byte Order Mark functions |
| 587 | |
| 588 | bool chompUTF8BOM( const char *inString, char **outStringPtr ) |
| 589 | { |
| 590 | *outStringPtr = const_cast<char *>( inString ); |
| 591 | |
| 592 | bool valid = false; |
| 593 | if (inString[0] && inString[1] && inString[2]) |
| 594 | { |
| 595 | U8 bom[4]; |
| 596 | dMemcpy(bom, inString, 4); |
| 597 | valid = isValidUTF8BOM(bom); |
| 598 | } |
| 599 | |
| 600 | // This is hackey, but I am not sure the best way to do it at the present. |
| 601 | // The only valid BOM is a UTF8 BOM, which is 3 bytes, even though we read |
| 602 | // 4 bytes because it could possibly be a UTF32 BOM, and we want to provide |
| 603 | // an accurate error message. Perhaps this could be re-worked when more UTF |
| 604 | // formats are supported to have isValidBOM return the size of the BOM, in |
| 605 | // bytes. |
| 606 | if( valid ) |
| 607 | (*outStringPtr) += 3; // SEE ABOVE!! -pw |
| 608 | |
| 609 | return valid; |
| 610 | } |
| 611 | |
| 612 | bool isValidUTF8BOM( U8 bom[4] ) |
| 613 | { |
no test coverage detected