Reports the error in parsing multibyte characters with leading bytes and current locale. Used in Utf8CaseConversion().
| 361 | /// Reports the error in parsing multibyte characters with leading bytes and current |
| 362 | /// locale. Used in Utf8CaseConversion(). |
| 363 | static void ReportErrorBytes(FunctionContext* context, const StringVal& str, |
| 364 | int current_idx) { |
| 365 | DCHECK_LT(current_idx, str.len); |
| 366 | stringstream ss; |
| 367 | ss << "[0x" << std::hex << (int)DCHECK_NOTNULL(str.ptr)[current_idx]; |
| 368 | for (int k = 1; k < 4 && current_idx + k < str.len; ++k) { |
| 369 | ss << ", 0x" << std::hex << (int)str.ptr[current_idx + k]; |
| 370 | } |
| 371 | ss << "]"; |
| 372 | context->AddWarning(Substitute( |
| 373 | "Illegal multi-byte character in string. Leading bytes: $0. Current locale: $1", |
| 374 | ss.str(), std::locale("").name()).c_str()); |
| 375 | } |
| 376 | |
| 377 | /// Converts string based on the transform function 'fn'. The unit of the conversion is |
| 378 | /// a wchar_t (i.e. uint32_t) which is parsed from multi bytes using std::mbtowc(). |
no test coverage detected