MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / chompUTF8BOM

Function chompUTF8BOM

Engine/source/core/strings/unicode.cpp:588–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

586// Byte Order Mark functions
587
588bool 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
612bool isValidUTF8BOM( U8 bom[4] )
613{

Callers 3

compileMethod · 0.85
compileExecMethod · 0.85
lang.cppFile · 0.85

Calls 2

isValidUTF8BOMFunction · 0.85
dMemcpyFunction · 0.50

Tested by

no test coverage detected