Ticket #4433: utf8_decode_warn_instead_of_breakpoint_v1.patch

File utf8_decode_warn_instead_of_breakpoint_v1.patch, 1.6 KB (added by elexis, 7 years ago)
  • source/lib/utf8.cpp

     
    1 /* Copyright (c) 2010 Wildfire Games
     1/* Copyright (c) 2016 Wildfire Games
    22 *
    33 * Permission is hereby granted, free of charge, to any person obtaining
    44 * a copy of this software and associated documentation files (the
    55 * "Software"), to deal in the Software without restriction, including
    66 * without limitation the rights to use, copy, modify, merge, publish,
     
    1919 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    2020 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    2121 */
    2222
    2323#include "precompiled.h"
     24
    2425#include "lib/utf8.h"
     26#include "ps/CLogger.h"
    2527
    2628static const StatusDefinition utf8StatusDefinitions[] = {
    2729    { ERR::UTF8_SURROGATE, L"UTF-16 surrogate pairs aren't supported" },
    2830    { ERR::UTF8_OUTSIDE_BMP, L"Code point outside BMP (> 0x10000)" },
    2931    { ERR::UTF8_NONCHARACTER, L"Noncharacter (e.g. WEOF)" },
    typedef u32 UTF32;  
    7577// called from ReplaceIfInvalid and UTF8Codec::Decode
    7678static UTF32 RaiseError(Status err, Status* perr)
    7779{
    7880    if(perr)    // caller wants return code, not warning dialog
    7981    {
    80         if(*perr == INFO::OK)   // only return the first error (see header)
     82        if (*perr == INFO::OK)  // only return the first error (see header)
    8183            *perr = err;
    8284    }
    8385    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    }
    8590
    8691    return 0xFFFDul;    // replacement character
    8792}
    8893
    8994