Ticket #4433: utf8_decode_warn_instead_of_breakpoint_v1.patch
File utf8_decode_warn_instead_of_breakpoint_v1.patch, 1.6 KB (added by , 7 years ago) |
---|
-
source/lib/utf8.cpp
1 /* Copyright (c) 201 0Wildfire Games1 /* Copyright (c) 2016 Wildfire Games 2 2 * 3 3 * Permission is hereby granted, free of charge, to any person obtaining 4 4 * a copy of this software and associated documentation files (the 5 5 * "Software"), to deal in the Software without restriction, including 6 6 * without limitation the rights to use, copy, modify, merge, publish, … … 19 19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 20 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 21 */ 22 22 23 23 #include "precompiled.h" 24 24 25 #include "lib/utf8.h" 26 #include "ps/CLogger.h" 25 27 26 28 static const StatusDefinition utf8StatusDefinitions[] = { 27 29 { ERR::UTF8_SURROGATE, L"UTF-16 surrogate pairs aren't supported" }, 28 30 { ERR::UTF8_OUTSIDE_BMP, L"Code point outside BMP (> 0x10000)" }, 29 31 { ERR::UTF8_NONCHARACTER, L"Noncharacter (e.g. WEOF)" }, … … typedef u32 UTF32; 75 77 // called from ReplaceIfInvalid and UTF8Codec::Decode 76 78 static UTF32 RaiseError(Status err, Status* perr) 77 79 { 78 80 if(perr) // caller wants return code, not warning dialog 79 81 { 80 if (*perr == INFO::OK) // only return the first error (see header)82 if (*perr == INFO::OK) // only return the first error (see header) 81 83 *perr = err; 82 84 } 83 85 else 84 DEBUG_WARN_ERR(err); 86 { 87 wchar_t error[200]; 88 LOGWARNING("UTF8 error: %s", utf8_from_wstring(StatusDescription(err, error, ARRAY_SIZE(error)))); 89 } 85 90 86 91 return 0xFFFDul; // replacement character 87 92 } 88 93 89 94