| 610 | } |
| 611 | |
| 612 | bool isValidUTF8BOM( U8 bom[4] ) |
| 613 | { |
| 614 | // Is it a BOM? |
| 615 | if( bom[0] == 0 ) |
| 616 | { |
| 617 | // Could be UTF32BE |
| 618 | if( bom[1] == 0 && bom[2] == 0xFE && bom[3] == 0xFF ) |
| 619 | { |
| 620 | Con::warnf( "Encountered a UTF32 BE BOM in this file; Torque does NOT support this file encoding. Use UTF8!" ); |
| 621 | return false; |
| 622 | } |
| 623 | |
| 624 | return false; |
| 625 | } |
| 626 | else if( bom[0] == 0xFF ) |
| 627 | { |
| 628 | // It's little endian, either UTF16 or UTF32 |
| 629 | if( bom[1] == 0xFE ) |
| 630 | { |
| 631 | if( bom[2] == 0 && bom[3] == 0 ) |
| 632 | Con::warnf( "Encountered a UTF32 LE BOM in this file; Torque does NOT support this file encoding. Use UTF8!" ); |
| 633 | else |
| 634 | Con::warnf( "Encountered a UTF16 LE BOM in this file; Torque does NOT support this file encoding. Use UTF8!" ); |
| 635 | } |
| 636 | |
| 637 | return false; |
| 638 | } |
| 639 | else if( bom[0] == 0xFE && bom[1] == 0xFF ) |
| 640 | { |
| 641 | Con::warnf( "Encountered a UTF16 BE BOM in this file; Torque does NOT support this file encoding. Use UTF8!" ); |
| 642 | return false; |
| 643 | } |
| 644 | else if( bom[0] == 0xEF && bom[1] == 0xBB && bom[2] == 0xBF ) |
| 645 | { |
| 646 | // Can enable this if you want -pw |
| 647 | //Con::printf("Encountered a UTF8 BOM. Torque supports this."); |
| 648 | return true; |
| 649 | } |
| 650 | |
| 651 | // Don't print out an error message here, because it will try this with |
| 652 | // every script. -pw |
| 653 | return false; |
| 654 | } |