foobar2000 SDK  2015-08-03
string_conv.cpp
Go to the documentation of this file.
1 #include "pfc.h"
2 
3 
4 
5 namespace {
6  template<typename t_char, bool isChecked = true>
7  class string_writer_t {
8  public:
9  string_writer_t(t_char * p_buffer,t_size p_size) : m_buffer(p_buffer), m_size(p_size), m_writeptr(0) {}
10 
11  void write(t_char p_char) {
12  if (isChecked) {
13  if (m_writeptr < m_size) {
14  m_buffer[m_writeptr++] = p_char;
15  }
16  } else {
17  m_buffer[m_writeptr++] = p_char;
18  }
19  }
20  void write_multi(const t_char * p_buffer,t_size p_count) {
21  if (isChecked) {
22  const t_size delta = pfc::min_t<t_size>(p_count,m_size-m_writeptr);
23  for(t_size n=0;n<delta;n++) {
24  m_buffer[m_writeptr++] = p_buffer[n];
25  }
26  } else {
27  for(t_size n = 0; n < p_count; ++n) {
28  m_buffer[m_writeptr++] = p_buffer[n];
29  }
30  }
31  }
32 
33  void write_as_utf8(unsigned p_char) {
34  if (isChecked) {
35  char temp[6];
36  t_size n = pfc::utf8_encode_char(p_char,temp);
37  write_multi(temp,n);
38  } else {
39  m_writeptr += pfc::utf8_encode_char(p_char, m_buffer + m_writeptr);
40  }
41  }
42 
43  void write_as_wide(unsigned p_char) {
44  if (isChecked) {
45  wchar_t temp[2];
46  t_size n = pfc::wide_encode_char(p_char,temp);
47  write_multi(temp,n);
48  } else {
49  m_writeptr += pfc::wide_encode_char(p_char, m_buffer + m_writeptr);
50  }
51  }
52 
53  t_size finalize() {
54  if (isChecked) {
55  if (m_size == 0) return 0;
56  t_size terminator = pfc::min_t<t_size>(m_writeptr,m_size-1);
57  m_buffer[terminator] = 0;
58  return terminator;
59  } else {
60  m_buffer[m_writeptr] = 0;
61  return m_writeptr;
62  }
63  }
64  bool is_overrun() const {
65  return m_writeptr >= m_size;
66  }
67  private:
68  t_char * m_buffer;
69  t_size m_size;
70  t_size m_writeptr;
71  };
72 
73 
74 
75 
76  static const uint16_t mappings1252[] = {
77  /*0x80*/ 0x20AC, // #EURO SIGN
78  /*0x81*/ 0, // #UNDEFINED
79  /*0x82*/ 0x201A, // #SINGLE LOW-9 QUOTATION MARK
80  /*0x83*/ 0x0192, // #LATIN SMALL LETTER F WITH HOOK
81  /*0x84*/ 0x201E, // #DOUBLE LOW-9 QUOTATION MARK
82  /*0x85*/ 0x2026, // #HORIZONTAL ELLIPSIS
83  /*0x86*/ 0x2020, // #DAGGER
84  /*0x87*/ 0x2021, // #DOUBLE DAGGER
85  /*0x88*/ 0x02C6, // #MODIFIER LETTER CIRCUMFLEX ACCENT
86  /*0x89*/ 0x2030, // #PER MILLE SIGN
87  /*0x8A*/ 0x0160, // #LATIN CAPITAL LETTER S WITH CARON
88  /*0x8B*/ 0x2039, // #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
89  /*0x8C*/ 0x0152, // #LATIN CAPITAL LIGATURE OE
90  /*0x8D*/ 0, // #UNDEFINED
91  /*0x8E*/ 0x017D, // #LATIN CAPITAL LETTER Z WITH CARON
92  /*0x8F*/ 0, // #UNDEFINED
93  /*0x90*/ 0, // #UNDEFINED
94  /*0x91*/ 0x2018, // #LEFT SINGLE QUOTATION MARK
95  /*0x92*/ 0x2019, // #RIGHT SINGLE QUOTATION MARK
96  /*0x93*/ 0x201C, // #LEFT DOUBLE QUOTATION MARK
97  /*0x94*/ 0x201D, // #RIGHT DOUBLE QUOTATION MARK
98  /*0x95*/ 0x2022, // #BULLET
99  /*0x96*/ 0x2013, // #EN DASH
100  /*0x97*/ 0x2014, // #EM DASH
101  /*0x98*/ 0x02DC, // #SMALL TILDE
102  /*0x99*/ 0x2122, // #TRADE MARK SIGN
103  /*0x9A*/ 0x0161, // #LATIN SMALL LETTER S WITH CARON
104  /*0x9B*/ 0x203A, // #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
105  /*0x9C*/ 0x0153, // #LATIN SMALL LIGATURE OE
106  /*0x9D*/ 0, // #UNDEFINED
107  /*0x9E*/ 0x017E, // #LATIN SMALL LETTER Z WITH CARON
108  /*0x9F*/ 0x0178, // #LATIN CAPITAL LETTER Y WITH DIAERESIS
109  };
110 
111  static bool charImport1252(uint32_t & unichar, char c) {
112  uint8_t uc = (uint8_t) c;
113  if (uc == 0) return false;
114  else if (uc < 0x80) {unichar = uc; return true;}
115  else if (uc < 0xA0) {
116  uint32_t t = mappings1252[uc-0x80];
117  if (t == 0) return false;
118  unichar = t; return true;
119  } else {
120  unichar = uc; return true;
121  }
122  }
123 
124  static bool charExport1252(char & c, uint32_t unichar) {
125  if (unichar == 0) return false;
126  else if (unichar < 0x80 || (unichar >= 0xa0 && unichar <= 0xFF)) {c = (char)(uint8_t)unichar; return true;}
127  for(size_t walk = 0; walk < PFC_TABSIZE(mappings1252); ++walk) {
128  if (unichar == mappings1252[walk]) {
129  c = (char)(uint8_t)(walk + 0x80);
130  return true;
131  }
132  }
133  return false;
134  }
135  struct asciiMap_t {uint16_t from; uint8_t to;};
136  static const asciiMap_t g_asciiMap[] = {
137  {160,32},{161,33},{162,99},{164,36},{165,89},{166,124},{169,67},{170,97},{171,60},{173,45},{174,82},{178,50},{179,51},{183,46},{184,44},{185,49},{186,111},{187,62},{192,65},{193,65},{194,65},{195,65},{196,65},{197,65},{198,65},{199,67},{200,69},{201,69},{202,69},{203,69},{204,73},{205,73},{206,73},{207,73},{208,68},{209,78},{210,79},{211,79},{212,79},{213,79},{214,79},{216,79},{217,85},{218,85},{219,85},{220,85},{221,89},{224,97},{225,97},{226,97},{227,97},{228,97},{229,97},{230,97},{231,99},{232,101},{233,101},{234,101},{235,101},{236,105},{237,105},{238,105},{239,105},{241,110},{242,111},{243,111},{244,111},{245,111},{246,111},{248,111},{249,117},{250,117},{251,117},{252,117},{253,121},{255,121},{256,65},{257,97},{258,65},{259,97},{260,65},{261,97},{262,67},{263,99},{264,67},{265,99},{266,67},{267,99},{268,67},{269,99},{270,68},{271,100},{272,68},{273,100},{274,69},{275,101},{276,69},{277,101},{278,69},{279,101},{280,69},{281,101},{282,69},{283,101},{284,71},{285,103},{286,71},{287,103},{288,71},{289,103},{290,71},{291,103},{292,72},{293,104},{294,72},{295,104},{296,73},{297,105},{298,73},{299,105},{300,73},{301,105},{302,73},{303,105},{304,73},{305,105},{308,74},{309,106},{310,75},{311,107},{313,76},{314,108},{315,76},{316,108},{317,76},{318,108},{321,76},{322,108},{323,78},{324,110},{325,78},{326,110},{327,78},{328,110},{332,79},{333,111},{334,79},{335,111},{336,79},{337,111},{338,79},{339,111},{340,82},{341,114},{342,82},{343,114},{344,82},{345,114},{346,83},{347,115},{348,83},{349,115},{350,83},{351,115},{352,83},{353,115},{354,84},{355,116},{356,84},{357,116},{358,84},{359,116},{360,85},{361,117},{362,85},{363,117},{364,85},{365,117},{366,85},{367,117},{368,85},{369,117},{370,85},{371,117},{372,87},{373,119},{374,89},{375,121},{376,89},{377,90},{378,122},{379,90},{380,122},{381,90},{382,122},{384,98},{393,68},{401,70},{402,102},{407,73},{410,108},{415,79},{416,79},{417,111},{427,116},{430,84},{431,85},{432,117},{438,122},{461,65},{462,97},{463,73},{464,105},{465,79},{466,111},{467,85},{468,117},{469,85},{470,117},{471,85},{472,117},{473,85},{474,117},{475,85},{476,117},{478,65},{479,97},{484,71},{485,103},{486,71},{487,103},{488,75},{489,107},{490,79},{491,111},{492,79},{493,111},{496,106},{609,103},{697,39},{698,34},{700,39},{708,94},{710,94},{712,39},{715,96},{717,95},{732,126},{768,96},{770,94},{771,126},{782,34},{817,95},{818,95},{8192,32},{8193,32},{8194,32},{8195,32},{8196,32},{8197,32},{8198,32},{8208,45},{8209,45},{8211,45},{8212,45},{8216,39},{8217,39},{8218,44},{8220,34},{8221,34},{8222,34},{8226,46},{8230,46},{8242,39},{8245,96},{8249,60},{8250,62},{8482,84},{65281,33},{65282,34},{65283,35},{65284,36},{65285,37},{65286,38},{65287,39},{65288,40},{65289,41},{65290,42},{65291,43},{65292,44},{65293,45},{65294,46},{65295,47},{65296,48},{65297,49},{65298,50},{65299,51},{65300,52},{65301,53},{65302,54},{65303,55},{65304,56},{65305,57},{65306,58},{65307,59},{65308,60},{65309,61},{65310,62},{65312,64},{65313,65},{65314,66},{65315,67},{65316,68},{65317,69},{65318,70},{65319,71},{65320,72},{65321,73},{65322,74},{65323,75},{65324,76},{65325,77},{65326,78},{65327,79},{65328,80},{65329,81},{65330,82},{65331,83},{65332,84},{65333,85},{65334,86},{65335,87},{65336,88},{65337,89},{65338,90},{65339,91},{65340,92},{65341,93},{65342,94},{65343,95},{65344,96},{65345,97},{65346,98},{65347,99},{65348,100},{65349,101},{65350,102},{65351,103},{65352,104},{65353,105},{65354,106},{65355,107},{65356,108},{65357,109},{65358,110},{65359,111},{65360,112},{65361,113},{65362,114},{65363,115},{65364,116},{65365,117},{65366,118},{65367,119},{65368,120},{65369,121},{65370,122},{65371,123},{65372,124},{65373,125},{65374,126}};
138 
139 }
140 
141 namespace pfc {
142  namespace stringcvt {
143 
144  char charToASCII( unsigned c ) {
145  if (c < 128) return (char)c;
146  unsigned lo = 0, hi = PFC_TABSIZE(g_asciiMap);
147  while( lo < hi ) {
148  const unsigned mid = (lo + hi) / 2;
149  const asciiMap_t entry = g_asciiMap[mid];
150  if ( c > entry.from ) {
151  lo = mid + 1;
152  } else if (c < entry.from) {
153  hi = mid;
154  } else {
155  return (char)entry.to;
156  }
157  }
158  return '?';
159  }
160 
161  t_size convert_utf8_to_wide(wchar_t * p_out,t_size p_out_size,const char * p_in,t_size p_in_size) {
162  const t_size insize = p_in_size;
163  t_size inptr = 0;
164  string_writer_t<wchar_t> writer(p_out,p_out_size);
165 
166  while(inptr < insize && !writer.is_overrun()) {
167  unsigned newchar = 0;
168  t_size delta = utf8_decode_char(p_in + inptr,newchar,insize - inptr);
169  if (delta == 0 || newchar == 0) break;
170  PFC_ASSERT(inptr + delta <= insize);
171  inptr += delta;
172  writer.write_as_wide(newchar);
173  }
174 
175  return writer.finalize();
176  }
177 
178  t_size convert_utf8_to_wide_unchecked(wchar_t * p_out,const char * p_in) {
179  t_size inptr = 0;
180  string_writer_t<wchar_t,false> writer(p_out,~0);
181 
182  while(!writer.is_overrun()) {
183  unsigned newchar = 0;
184  t_size delta = utf8_decode_char(p_in + inptr,newchar);
185  if (delta == 0 || newchar == 0) break;
186  inptr += delta;
187  writer.write_as_wide(newchar);
188  }
189 
190  return writer.finalize();
191  }
192 
193  t_size convert_wide_to_utf8(char * p_out,t_size p_out_size,const wchar_t * p_in,t_size p_in_size) {
194  const t_size insize = p_in_size;
195  t_size inptr = 0;
196  string_writer_t<char> writer(p_out,p_out_size);
197 
198  while(inptr < insize && !writer.is_overrun()) {
199  unsigned newchar = 0;
200  t_size delta = wide_decode_char(p_in + inptr,&newchar,insize - inptr);
201  if (delta == 0 || newchar == 0) break;
202  PFC_ASSERT(inptr + delta <= insize);
203  inptr += delta;
204  writer.write_as_utf8(newchar);
205  }
206 
207  return writer.finalize();
208  }
209 
210  t_size estimate_utf8_to_wide(const char * p_in) {
211  t_size inptr = 0;
212  t_size retval = 1;//1 for null terminator
213  for(;;) {
214  unsigned newchar = 0;
215  t_size delta = utf8_decode_char(p_in + inptr,newchar);
216  if (delta == 0 || newchar == 0) break;
217  inptr += delta;
218 
219  {
220  wchar_t temp[2];
221  retval += wide_encode_char(newchar,temp);
222  }
223  }
224  return retval;
225  }
226 
227  t_size estimate_utf8_to_wide(const char * p_in,t_size p_in_size) {
228  const t_size insize = p_in_size;
229  t_size inptr = 0;
230  t_size retval = 1;//1 for null terminator
231  while(inptr < insize) {
232  unsigned newchar = 0;
233  t_size delta = utf8_decode_char(p_in + inptr,newchar,insize - inptr);
234  if (delta == 0 || newchar == 0) break;
235  PFC_ASSERT(inptr + delta <= insize);
236  inptr += delta;
237 
238  {
239  wchar_t temp[2];
240  retval += wide_encode_char(newchar,temp);
241  }
242  }
243  return retval;
244  }
245 
246  t_size estimate_wide_to_utf8(const wchar_t * p_in,t_size p_in_size) {
247  const t_size insize = p_in_size;
248  t_size inptr = 0;
249  t_size retval = 1;//1 for null terminator
250  while(inptr < insize) {
251  unsigned newchar = 0;
252  t_size delta = wide_decode_char(p_in + inptr,&newchar,insize - inptr);
253  if (delta == 0 || newchar == 0) break;
254  PFC_ASSERT(inptr + delta <= insize);
255  inptr += delta;
256 
257  {
258  char temp[6];
259  delta = utf8_encode_char(newchar,temp);
260  if (delta == 0) break;
261  retval += delta;
262  }
263  }
264  return retval;
265  }
266 
267  t_size estimate_wide_to_win1252( const wchar_t * p_in, t_size p_in_size ) {
268  const t_size insize = p_in_size;
269  t_size inptr = 0;
270  t_size retval = 1;//1 for null terminator
271  while(inptr < insize) {
272  unsigned newchar = 0;
273  t_size delta = wide_decode_char(p_in + inptr,&newchar,insize - inptr);
274  if (delta == 0 || newchar == 0) break;
275  PFC_ASSERT(inptr + delta <= insize);
276  inptr += delta;
277 
278  ++retval;
279  }
280  return retval;
281 
282  }
283 
284  t_size convert_wide_to_win1252( char * p_out, t_size p_out_size, const wchar_t * p_in, t_size p_in_size ) {
285  const t_size insize = p_in_size;
286  t_size inptr = 0;
287  string_writer_t<char> writer(p_out,p_out_size);
288 
289  while(inptr < insize && !writer.is_overrun()) {
290  unsigned newchar = 0;
291  t_size delta = wide_decode_char(p_in + inptr,&newchar,insize - inptr);
292  if (delta == 0 || newchar == 0) break;
293  PFC_ASSERT(inptr + delta <= insize);
294  inptr += delta;
295 
296  char temp;
297  if (!charExport1252( temp, newchar )) temp = '?';
298  writer.write( temp );
299  }
300 
301  return writer.finalize();
302 
303  }
304 
305  t_size estimate_win1252_to_wide( const char * p_source, t_size p_source_size ) {
306  return strlen_max_t( p_source, p_source_size ) + 1;
307  }
308 
309  t_size convert_win1252_to_wide( wchar_t * p_out, t_size p_out_size, const char * p_in, t_size p_in_size ) {
310  const t_size insize = p_in_size;
311  t_size inptr = 0;
312  string_writer_t<wchar_t> writer(p_out,p_out_size);
313 
314  while(inptr < insize && !writer.is_overrun()) {
315  char inChar = p_in[inptr];
316  if (inChar == 0) break;
317  ++inptr;
318 
319  unsigned out;
320  if (!charImport1252( out , inChar )) out = '?';
321  writer.write_as_wide( out );
322  }
323 
324  return writer.finalize();
325  }
326 
327  t_size estimate_utf8_to_win1252( const char * p_in, t_size p_in_size ) {
328  const t_size insize = p_in_size;
329  t_size inptr = 0;
330  t_size retval = 1;//1 for null terminator
331  while(inptr < insize) {
332  unsigned newchar = 0;
333  t_size delta = utf8_decode_char(p_in + inptr,newchar,insize - inptr);
334  if (delta == 0 || newchar == 0) break;
335  PFC_ASSERT(inptr + delta <= insize);
336  inptr += delta;
337 
338  ++retval;
339  }
340  return retval;
341  }
342  t_size convert_utf8_to_win1252( char * p_out, t_size p_out_size, const char * p_in, t_size p_in_size ) {
343  const t_size insize = p_in_size;
344  t_size inptr = 0;
345  string_writer_t<char> writer(p_out,p_out_size);
346 
347  while(inptr < insize && !writer.is_overrun()) {
348  unsigned newchar = 0;
349  t_size delta = utf8_decode_char(p_in + inptr,newchar,insize - inptr);
350  if (delta == 0 || newchar == 0) break;
351  PFC_ASSERT(inptr + delta <= insize);
352  inptr += delta;
353 
354  char temp;
355  if (!charExport1252( temp, newchar )) temp = '?';
356  writer.write( temp );
357  }
358 
359  return writer.finalize();
360  }
361 
362  t_size estimate_win1252_to_utf8( const char * p_in, t_size p_in_size ) {
363  const size_t insize = p_in_size;
364  t_size inptr = 0;
365  t_size retval = 1; // 1 for null terminator
366  while(inptr < insize) {
367  unsigned newchar;
368  char c = p_in[inptr];
369  if (c == 0) break;
370  ++inptr;
371  if (!charImport1252( newchar, c)) newchar = '?';
372 
373  char temp[6];
374  retval += pfc::utf8_encode_char( newchar, temp );
375  }
376  return retval;
377  }
378 
379  t_size convert_win1252_to_utf8( char * p_out, t_size p_out_size, const char * p_in, t_size p_in_size ) {
380  const t_size insize = p_in_size;
381  t_size inptr = 0;
382  string_writer_t<char> writer(p_out,p_out_size);
383 
384  while(inptr < insize && !writer.is_overrun()) {
385  char inChar = p_in[inptr];
386  if (inChar == 0) break;
387  ++inptr;
388 
389  unsigned out;
390  if (!charImport1252( out , inChar )) out = '?';
391  writer.write_as_utf8( out );
392  }
393 
394  return writer.finalize();
395  }
396 
397  t_size estimate_utf8_to_ascii( const char * p_source, t_size p_source_size ) {
398  return estimate_utf8_to_win1252( p_source, p_source_size );
399  }
400  t_size convert_utf8_to_ascii( char * p_out, t_size p_out_size, const char * p_in, t_size p_in_size ) {
401  const t_size insize = p_in_size;
402  t_size inptr = 0;
403  string_writer_t<char> writer(p_out,p_out_size);
404 
405  while(inptr < insize && !writer.is_overrun()) {
406  unsigned newchar = 0;
407  t_size delta = utf8_decode_char(p_in + inptr,newchar,insize - inptr);
408  if (delta == 0 || newchar == 0) break;
409  PFC_ASSERT(inptr + delta <= insize);
410  inptr += delta;
411 
412  writer.write( charToASCII(newchar) );
413  }
414 
415  return writer.finalize();
416  }
417 
418  }
419 }
420 
421 #ifdef _WINDOWS
422 
423 
424 namespace pfc {
425  namespace stringcvt {
426 
427 
428  t_size convert_codepage_to_wide(unsigned p_codepage,wchar_t * p_out,t_size p_out_size,const char * p_source,t_size p_source_size) {
429  if (p_out_size == 0) return 0;
430  memset(p_out,0,p_out_size * sizeof(*p_out));
431  MultiByteToWideChar(p_codepage,0,p_source,p_source_size,p_out,p_out_size);
432  p_out[p_out_size-1] = 0;
433  return wcslen(p_out);
434  }
435 
436  t_size convert_wide_to_codepage(unsigned p_codepage,char * p_out,t_size p_out_size,const wchar_t * p_source,t_size p_source_size) {
437  if (p_out_size == 0) return 0;
438  memset(p_out,0,p_out_size * sizeof(*p_out));
439  WideCharToMultiByte(p_codepage,0,p_source,p_source_size,p_out,p_out_size,0,FALSE);
440  p_out[p_out_size-1] = 0;
441  return strlen(p_out);
442  }
443 
444  t_size estimate_codepage_to_wide(unsigned p_codepage,const char * p_source,t_size p_source_size) {
445  return MultiByteToWideChar(p_codepage,0,p_source,strlen_max(p_source,p_source_size),0,0) + 1;
446  }
447  t_size estimate_wide_to_codepage(unsigned p_codepage,const wchar_t * p_source,t_size p_source_size) {
448  return WideCharToMultiByte(p_codepage,0,p_source,wcslen_max(p_source,p_source_size),0,0,0,FALSE) + 1;
449  }
450  }
451 
452 }
453 
454 #endif //_WINDOWS
t_size convert_codepage_to_wide(unsigned p_codepage, wchar_t *p_out, t_size p_out_size, const char *p_source, t_size p_source_size)
Converts string from specified codepage to wide character.
t_size estimate_codepage_to_wide(unsigned p_codepage, const char *p_source, t_size p_source_size)
Estimates buffer size required to convert specified string from specified codepage to wide character...
t_size utf8_encode_char(unsigned c, char *out)
Definition: utf8.cpp:113
t_size estimate_utf8_to_wide(const char *p_in, t_size p_in_size)
Estimates buffer size required to convert specified UTF-8 string to widechar.
t_size wide_decode_char(const wchar_t *p_source, unsigned *p_out, t_size p_source_length=~0)
Definition: utf8.cpp:217
t_size convert_wide_to_utf8(char *p_out, t_size p_out_size, const wchar_t *p_in, t_size p_in_size)
Converts wide character string to UTF-8.
t_size estimate_wide_to_utf8(const wchar_t *p_in, t_size p_in_size)
Estimates buffer size required to convert specified wide character string to UTF-8.
t_size convert_utf8_to_win1252(char *p_out, t_size p_out_size, const char *p_in, t_size p_in_size)
t_size estimate_utf8_to_ascii(const char *p_source, t_size p_source_size)
t_size estimate_win1252_to_wide(const char *p_source, t_size p_source_size)
t_size strlen_max(const char *ptr, t_size max)
Definition: string_base.h:91
t_size convert_win1252_to_utf8(char *p_out, t_size p_out_size, const char *p_in, t_size p_in_size)
size_t t_size
Definition: int_types.h:48
t_size estimate_wide_to_win1252(const wchar_t *p_in, t_size p_in_size)
t_size convert_utf8_to_wide(wchar_t *p_out, t_size p_out_size, const char *p_in, t_size p_in_size)
Converts UTF-8 characters to wide character.
t_size convert_win1252_to_wide(wchar_t *p_out, t_size p_out_size, const char *p_in, t_size p_in_size)
t_size convert_utf8_to_wide_unchecked(wchar_t *p_out, const char *p_in)
t_size convert_wide_to_codepage(unsigned p_codepage, char *p_out, t_size p_out_size, const wchar_t *p_source, t_size p_source_size)
Converts string from wide character to specified codepage.
t_size strlen_max_t(const t_char *ptr, t_size max)
Definition: string_base.h:84
t_size convert_utf8_to_ascii(char *p_out, t_size p_out_size, const char *p_in, t_size p_in_size)
t_size estimate_utf8_to_win1252(const char *p_in, t_size p_in_size)
void write(const service_ptr_t< file > &p_file, abort_callback &p_abort, const char *p_string, bool is_utf8)
t_size utf8_decode_char(const char *src, unsigned &out, t_size src_bytes)
Definition: utf8.cpp:64
t_size convert_wide_to_win1252(char *p_out, t_size p_out_size, const wchar_t *p_in, t_size p_in_size)
t_size estimate_wide_to_codepage(unsigned p_codepage, const wchar_t *p_source, t_size p_source_size)
Estimates buffer size required to convert specified wide character string to specified codepage...
t_size estimate_win1252_to_utf8(const char *p_in, t_size p_in_size)
t_size wide_encode_char(unsigned c, wchar_t *out)
Definition: utf8.cpp:227
char charToASCII(unsigned c)
void write_multi(const service_ptr_t< file > &p_file, const file_info &p_info, abort_callback &p_abort, bool p_write_id3v1, bool p_write_id3v2, bool p_write_apev2)
Strips all recognized tags from the file and writes new tags with specified info according to paramet...
t_size wcslen_max(const wchar_t *ptr, t_size max)
Definition: string_base.h:92