MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / to_ascii

Function to_ascii

sql/sql_time.cc:229–250  ·  view source on GitHub ↗

Convert a string to 8-bit representation, for use in str_to_time/str_to_date/str_to_date. In the future to_ascii() can be extended to convert non-ASCII digits to ASCII digits (for example, ARABIC-INDIC, DEVANAGARI, BENGALI, and so on) so DATE/TIME/DATETIME values understand digits in the respected scripts. */

Source from the content-addressed store, hash-verified

227 respected scripts.
228*/
229static uint
230to_ascii(const CHARSET_INFO *cs,
231 const char *src, uint src_length,
232 char *dst, uint dst_length)
233
234{
235 int cnvres;
236 my_wc_t wc;
237 const char *srcend= src + src_length;
238 char *dst0= dst, *dstend= dst + dst_length - 1;
239 while (dst < dstend &&
240 (cnvres= (cs->cset->mb_wc)(cs, &wc,
241 (const uchar*) src,
242 (const uchar*) srcend)) > 0 &&
243 wc < 128)
244 {
245 src+= cnvres;
246 *dst++= wc;
247 }
248 *dst= '\0';
249 return dst - dst0;
250}
251
252
253/* Character set-aware version of str_to_time() */

Callers 2

str_to_timeFunction · 0.85
str_to_datetimeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected