MCPcopy Create free account
hub / github.com/MariaDB/server / strconvert

Function strconvert

sql/strfunc.cc:327–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325
326
327uint strconvert(CHARSET_INFO *from_cs, const char *from, size_t from_length,
328 CHARSET_INFO *to_cs, char *to, size_t to_length, uint *errors)
329{
330 int cnvres;
331 my_wc_t wc;
332 char *to_start= to;
333 uchar *to_end= (uchar*) to + to_length - 1;
334 const uchar *from_end= (const uchar*) from + from_length;
335 my_charset_conv_mb_wc mb_wc= from_cs->cset->mb_wc;
336 my_charset_conv_wc_mb wc_mb= to_cs->cset->wc_mb;
337 uint error_count= 0;
338
339 while (1)
340 {
341 if ((cnvres= (*mb_wc)(from_cs, &wc,
342 (uchar*) from, from_end)) > 0)
343 {
344 if (!wc)
345 break;
346 from+= cnvres;
347 }
348 else if (cnvres == MY_CS_ILSEQ)
349 {
350 error_count++;
351 from++;
352 wc= '?';
353 }
354 else
355 break; // Impossible char.
356
357outp:
358
359 if ((cnvres= (*wc_mb)(to_cs, wc, (uchar*) to, to_end)) > 0)
360 to+= cnvres;
361 else if (cnvres == MY_CS_ILUNI && wc != '?')
362 {
363 error_count++;
364 wc= '?';
365 goto outp;
366 }
367 else
368 break;
369 }
370 *to= '\0';
371 *errors= error_count;
372 return (uint32) (to - to_start);
373
374}
375
376
377/*

Callers 15

build_normalized_nameFunction · 0.85
add_name_to_bufferFunction · 0.85
add_identifierFunction · 0.85
filename_to_tablenameFunction · 0.85
tablename_to_filenameFunction · 0.85
load_data_tmp_prefixFunction · 0.85
rename_triggersFunction · 0.85
rename_in_stat_tablesFunction · 0.85
dict_scan_idFunction · 0.85
dict_fs2utf8Function · 0.85
ha_innodb.ccFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected