foobar2000 SDK  2015-08-03
string_conv.h
Go to the documentation of this file.
1 namespace pfc {
2 
3  namespace stringcvt {
10  t_size convert_utf8_to_wide(wchar_t * p_out,t_size p_out_size,const char * p_source,t_size p_source_size);
11 
12 
17  t_size estimate_utf8_to_wide(const char * p_source,t_size p_source_size);
18 
19  t_size estimate_utf8_to_wide(const char * p_source);
20 
27  t_size convert_wide_to_utf8(char * p_out,t_size p_out_size,const wchar_t * p_source,t_size p_source_size);
28 
33  t_size estimate_wide_to_utf8(const wchar_t * p_source,t_size p_source_size);
34 
35  t_size estimate_utf8_to_ascii( const char * p_source, t_size p_source_size );
36  t_size convert_utf8_to_ascii( char * p_out, t_size p_out_size, const char * p_source, t_size p_source_size );
37 
38  t_size estimate_wide_to_win1252( const wchar_t * p_source, t_size p_source_size );
39  t_size convert_wide_to_win1252( char * p_out, t_size p_out_size, const wchar_t * p_source, t_size p_source_size );
40  t_size estimate_win1252_to_wide( const char * p_source, t_size p_source_size );
41  t_size convert_win1252_to_wide( wchar_t * p_out, t_size p_out_size, const char * p_source, t_size p_source_size );
42 
43  t_size estimate_utf8_to_win1252( const char * p_source, t_size p_source_size );
44  t_size convert_utf8_to_win1252( char * p_out, t_size p_out_size, const char * p_source, t_size p_source_size );
45  t_size estimate_win1252_to_utf8( const char * p_source, t_size p_source_size );
46  t_size convert_win1252_to_utf8( char * p_out, t_size p_out_size, const char * p_source, t_size p_source_size );
47 
48 
49 
53  return sourceLen + 1;
54  }
55  inline t_size estimate_utf8_to_wide_quick(const char * source) {
56  return estimate_utf8_to_wide_quick(strlen(source));
57  }
58  inline t_size estimate_utf8_to_wide_quick(const char * source, t_size sourceLen) {
59  return estimate_utf8_to_wide_quick(strlen_max(source, sourceLen));
60  }
61  t_size convert_utf8_to_wide_unchecked(wchar_t * p_out,const char * p_source);
62 
63  template<typename t_char> const t_char * null_string_t();
64  template<> inline const char * null_string_t<char>() {return "";}
65  template<> inline const wchar_t * null_string_t<wchar_t>() {return L"";}
66 
67  template<typename t_char> t_size strlen_t(const t_char * p_string,t_size p_string_size = ~0) {
68  for(t_size n=0;n<p_string_size;n++) {
69  if (p_string[n] == 0) return n;
70  }
71  return p_string_size;
72  }
73 
74  template<typename t_char> bool string_is_empty_t(const t_char * p_string,t_size p_string_size = ~0) {
75  if (p_string_size == 0) return true;
76  return p_string[0] == 0;
77  }
78 
79  template<typename t_char,template<typename t_allocitem> class t_alloc = pfc::alloc_standard> class char_buffer_t {
80  public:
82  char_buffer_t(const char_buffer_t & p_source) : m_buffer(p_source.m_buffer) {}
83  void set_size(t_size p_count) {m_buffer.set_size(p_count);}
84  t_char * get_ptr_var() {return m_buffer.get_ptr();}
85  const t_char * get_ptr() const {
86  return m_buffer.get_size() > 0 ? m_buffer.get_ptr() : null_string_t<t_char>();
87  }
88  private:
90  };
91 
92  template<template<typename t_allocitem> class t_alloc = pfc::alloc_standard>
94  public:
96  string_utf8_from_wide_t(const wchar_t * p_source,t_size p_source_size = ~0) {convert(p_source,p_source_size);}
97 
98  void convert(const wchar_t * p_source,t_size p_source_size = ~0) {
99  t_size size = estimate_wide_to_utf8(p_source,p_source_size);
100  m_buffer.set_size(size);
101  convert_wide_to_utf8( m_buffer.get_ptr_var(),size,p_source,p_source_size);
102  }
103 
104  operator const char * () const {return get_ptr();}
105  const char * get_ptr() const {return m_buffer.get_ptr();}
106  const char * toString() const {return get_ptr();}
107  bool is_empty() const {return string_is_empty_t(get_ptr());}
108  t_size length() const {return strlen_t(get_ptr());}
109 
110  private:
112  };
114 
115  template<template<typename t_allocitem> class t_alloc = pfc::alloc_standard>
117  public:
119  string_wide_from_utf8_t(const char* p_source) {convert(p_source);}
120  string_wide_from_utf8_t(const char* p_source,t_size p_source_size) {convert(p_source,p_source_size);}
121 
122  void convert(const char* p_source,t_size p_source_size) {
123  const t_size size = estimate_size(p_source, p_source_size);
124  m_buffer.set_size(size);
125  convert_utf8_to_wide( m_buffer.get_ptr_var(),size,p_source,p_source_size );
126  }
127  void convert(const char * p_source) {
128  m_buffer.set_size( estimate_size(p_source) );
129  convert_utf8_to_wide_unchecked(m_buffer.get_ptr_var(), p_source);
130  }
131 
132  operator const wchar_t * () const {return get_ptr();}
133  const wchar_t * get_ptr() const {return m_buffer.get_ptr();}
134  bool is_empty() const {return string_is_empty_t(get_ptr());}
135  t_size length() const {return strlen_t(get_ptr());}
136 
137  void append(const char* p_source,t_size p_source_size) {
138  const t_size base = length();
139  const t_size size = estimate_size(p_source, p_source_size);
140  m_buffer.set_size(base + size);
141  convert_utf8_to_wide( m_buffer.get_ptr_var() + base, size, p_source, p_source_size );
142  }
143  void append(const char * p_source) {
144  const t_size base = length();
145  m_buffer.set_size( base + estimate_size(p_source) );
146  convert_utf8_to_wide_unchecked(m_buffer.get_ptr_var() + base, p_source);
147  }
148 
149  enum { alloc_prioritizes_speed = t_alloc<wchar_t>::alloc_prioritizes_speed };
150  private:
151 
152  inline t_size estimate_size(const char * source, t_size sourceLen) {
153  return alloc_prioritizes_speed ? estimate_utf8_to_wide_quick(source, sourceLen) : estimate_utf8_to_wide(source,sourceLen);
154  }
155  inline t_size estimate_size(const char * source) {
156  return alloc_prioritizes_speed ? estimate_utf8_to_wide_quick(source) : estimate_utf8_to_wide(source,~0);
157  }
159  };
162 
163 
164  template<template<typename t_allocitem> class t_alloc = pfc::alloc_standard>
166  public:
168  string_wide_from_win1252_t(const char * p_source,t_size p_source_size = ~0) {convert(p_source,p_source_size);}
169 
170  void convert(const char * p_source,t_size p_source_size = ~0) {
171  t_size size = estimate_win1252_to_wide(p_source,p_source_size);
172  m_buffer.set_size(size);
173  convert_win1252_to_wide(m_buffer.get_ptr_var(),size,p_source,p_source_size);
174  }
175 
176  operator const wchar_t * () const {return get_ptr();}
177  const wchar_t * get_ptr() const {return m_buffer.get_ptr();}
178  bool is_empty() const {return string_is_empty_t(get_ptr());}
179  t_size length() const {return strlen_t(get_ptr());}
180 
181  private:
183  };
185 
186 
187  template<template<typename t_allocitem> class t_alloc = pfc::alloc_standard>
189  public:
191  string_win1252_from_wide_t(const wchar_t * p_source,t_size p_source_size = ~0) {convert(p_source,p_source_size);}
192 
193  void convert(const wchar_t * p_source,t_size p_source_size = ~0) {
194  t_size size = estimate_wide_to_win1252(p_source,p_source_size);
195  m_buffer.set_size(size);
196  convert_wide_to_win1252(m_buffer.get_ptr_var(),size,p_source,p_source_size);
197  }
198 
199  operator const char * () const {return get_ptr();}
200  const char * get_ptr() const {return m_buffer.get_ptr();}
201  bool is_empty() const {return string_is_empty_t(get_ptr());}
202  t_size length() const {return strlen_t(get_ptr());}
203 
204  private:
206  };
208 
209 
210  template<template<typename t_allocitem> class t_alloc = pfc::alloc_standard>
212  public:
214  string_utf8_from_win1252_t(const char * p_source,t_size p_source_size = ~0) {convert(p_source,p_source_size);}
215 
216  void convert(const char * p_source,t_size p_source_size = ~0) {
217  t_size size = estimate_win1252_to_utf8(p_source,p_source_size);
218  m_buffer.set_size(size);
219  convert_win1252_to_utf8(m_buffer.get_ptr_var(),size,p_source,p_source_size);
220  }
221 
222  operator const char * () const {return get_ptr();}
223  const char * get_ptr() const {return m_buffer.get_ptr();}
224  bool is_empty() const {return string_is_empty_t(get_ptr());}
225  t_size length() const {return strlen_t(get_ptr());}
226 
227  private:
229  };
231 
232 
233  template<template<typename t_allocitem> class t_alloc = pfc::alloc_standard>
235  public:
237  string_win1252_from_utf8_t(const char * p_source,t_size p_source_size = ~0) {convert(p_source,p_source_size);}
238 
239  void convert(const char * p_source,t_size p_source_size = ~0) {
240  t_size size = estimate_utf8_to_win1252(p_source,p_source_size);
241  m_buffer.set_size(size);
242  convert_utf8_to_win1252(m_buffer.get_ptr_var(),size,p_source,p_source_size);
243  }
244 
245  operator const char * () const {return get_ptr();}
246  const char * get_ptr() const {return m_buffer.get_ptr();}
247  bool is_empty() const {return string_is_empty_t(get_ptr());}
248  t_size length() const {return strlen_t(get_ptr());}
249 
250  private:
252  };
254 
256  public:
258  string_ascii_from_utf8( const char * p_source, t_size p_source_size = ~0) { convert(p_source, p_source_size); }
259 
260  void convert( const char * p_source, t_size p_source_size = ~0) {
261  t_size size = estimate_utf8_to_ascii(p_source, p_source_size);
262  m_buffer.set_size(size);
263  convert_utf8_to_ascii(m_buffer.get_ptr_var(), size, p_source, p_source_size);
264  }
265 
266  operator const char * () const {return get_ptr();}
267  const char * get_ptr() const {return m_buffer.get_ptr();}
268  bool is_empty() const {return string_is_empty_t(get_ptr());}
269  t_size length() const {return strlen_t(get_ptr());}
270 
271  private:
273  };
274 
275  }
276 #ifdef _WINDOWS
277  namespace stringcvt {
278 
279  enum {
280  codepage_system = CP_ACP,
281  codepage_ascii = 20127,
283  };
284 
285 
286 
294  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);
295 
301  t_size estimate_codepage_to_wide(unsigned p_codepage,const char * p_source,t_size p_source_size);
302 
310  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);
311 
317  t_size estimate_wide_to_codepage(unsigned p_codepage,const wchar_t * p_source,t_size p_source_size);
318 
319 
326  inline t_size convert_ansi_to_wide(wchar_t * p_out,t_size p_out_size,const char * p_source,t_size p_source_size) {
327  return convert_codepage_to_wide(codepage_system,p_out,p_out_size,p_source,p_source_size);
328  }
329 
334  inline t_size estimate_ansi_to_wide(const char * p_source,t_size p_source_size) {
335  return estimate_codepage_to_wide(codepage_system,p_source,p_source_size);
336  }
337 
344  inline t_size convert_wide_to_ansi(char * p_out,t_size p_out_size,const wchar_t * p_source,t_size p_source_size) {
345  return convert_wide_to_codepage(codepage_system,p_out,p_out_size,p_source,p_source_size);
346  }
347 
352  inline t_size estimate_wide_to_ansi(const wchar_t * p_source,t_size p_source_size) {
353  return estimate_wide_to_codepage(codepage_system,p_source,p_source_size);
354  }
355 
356 
357  template<template<typename t_allocitem> class t_alloc = pfc::alloc_standard>
359  public:
362  string_wide_from_codepage_t(unsigned p_codepage,const char * p_source,t_size p_source_size = ~0) {convert(p_codepage,p_source,p_source_size);}
363 
364  void convert(unsigned p_codepage,const char * p_source,t_size p_source_size = ~0) {
365  t_size size = estimate_codepage_to_wide(p_codepage,p_source,p_source_size);
366  m_buffer.set_size(size);
367  convert_codepage_to_wide(p_codepage, m_buffer.get_ptr_var(),size,p_source,p_source_size);
368  }
369 
370  operator const wchar_t * () const {return get_ptr();}
371  const wchar_t * get_ptr() const {return m_buffer.get_ptr();}
372  bool is_empty() const {return string_is_empty_t(get_ptr());}
373  t_size length() const {return strlen_t(get_ptr());}
374 
375  private:
377  };
379 
380 
381  template<template<typename t_allocitem> class t_alloc = pfc::alloc_standard>
383  public:
386  string_codepage_from_wide_t(unsigned p_codepage,const wchar_t * p_source,t_size p_source_size = ~0) {convert(p_codepage,p_source,p_source_size);}
387 
388  void convert(unsigned p_codepage,const wchar_t * p_source,t_size p_source_size = ~0) {
389  t_size size = estimate_wide_to_codepage(p_codepage,p_source,p_source_size);
390  m_buffer.set_size(size);
391  convert_wide_to_codepage(p_codepage, m_buffer.get_ptr_var(),size,p_source,p_source_size);
392  }
393 
394  operator const char * () const {return get_ptr();}
395  const char * get_ptr() const {return m_buffer.get_ptr();}
396  bool is_empty() const {return string_is_empty_t(get_ptr());}
397  t_size length() const {return strlen_t(get_ptr());}
398 
399  private:
401  };
403 
405  public:
408  string_codepage_from_utf8(unsigned p_codepage,const char * p_source,t_size p_source_size = ~0) {convert(p_codepage,p_source,p_source_size);}
409 
410  void convert(unsigned p_codepage,const char * p_source,t_size p_source_size = ~0) {
412  temp.convert(p_source,p_source_size);
413  t_size size = estimate_wide_to_codepage(p_codepage,temp,~0);
414  m_buffer.set_size(size);
415  convert_wide_to_codepage(p_codepage,m_buffer.get_ptr_var(),size,temp,~0);
416  }
417 
418  operator const char * () const {return get_ptr();}
419  const char * get_ptr() const {return m_buffer.get_ptr();}
420  bool is_empty() const {return string_is_empty_t(get_ptr());}
421  t_size length() const {return strlen_t(get_ptr());}
422 
423  private:
425  };
426 
428  public:
431  string_utf8_from_codepage(unsigned p_codepage,const char * p_source,t_size p_source_size = ~0) {convert(p_codepage,p_source,p_source_size);}
432 
433  void convert(unsigned p_codepage,const char * p_source,t_size p_source_size = ~0) {
434  string_wide_from_codepage temp;
435  temp.convert(p_codepage,p_source,p_source_size);
436  t_size size = estimate_wide_to_utf8(temp,~0);
437  m_buffer.set_size(size);
438  convert_wide_to_utf8( m_buffer.get_ptr_var(),size,temp,~0);
439  }
440 
441  operator const char * () const {return get_ptr();}
442  const char * get_ptr() const {return m_buffer.get_ptr();}
443  bool is_empty() const {return string_is_empty_t(get_ptr());}
444  t_size length() const {return strlen_t(get_ptr());}
445 
446  private:
448  };
449 
450 
452  public:
455  string_utf8_from_ansi(const char * p_source,t_size p_source_size = ~0) : m_buffer(codepage_system,p_source,p_source_size) {}
456  operator const char * () const {return get_ptr();}
457  const char * get_ptr() const {return m_buffer.get_ptr();}
458  const char * toString() const {return get_ptr();}
459  bool is_empty() const {return string_is_empty_t(get_ptr());}
460  t_size length() const {return strlen_t(get_ptr());}
461  void convert(const char * p_source,t_size p_source_size = ~0) {m_buffer.convert(codepage_system,p_source,p_source_size);}
462 
463  private:
465  };
466 
468  public:
471  string_ansi_from_utf8(const char * p_source,t_size p_source_size = ~0) : m_buffer(codepage_system,p_source,p_source_size) {}
472  operator const char * () const {return get_ptr();}
473  const char * get_ptr() const {return m_buffer.get_ptr();}
474  bool is_empty() const {return string_is_empty_t(get_ptr());}
475  t_size length() const {return strlen_t(get_ptr());}
476 
477  void convert(const char * p_source,t_size p_source_size = ~0) {m_buffer.convert(codepage_system,p_source,p_source_size);}
478 
479  private:
481  };
482 
484  public:
487  string_wide_from_ansi(const char * p_source,t_size p_source_size = ~0) : m_buffer(codepage_system,p_source,p_source_size) {}
488  operator const wchar_t * () const {return get_ptr();}
489  const wchar_t * get_ptr() const {return m_buffer.get_ptr();}
490  bool is_empty() const {return string_is_empty_t(get_ptr());}
491  t_size length() const {return strlen_t(get_ptr());}
492 
493  void convert(const char * p_source,t_size p_source_size = ~0) {m_buffer.convert(codepage_system,p_source,p_source_size);}
494 
495  private:
496  string_wide_from_codepage m_buffer;
497  };
498 
500  public:
503  string_ansi_from_wide(const wchar_t * p_source,t_size p_source_size = ~0) : m_buffer(codepage_system,p_source,p_source_size) {}
504  operator const char * () const {return get_ptr();}
505  const char * get_ptr() const {return m_buffer.get_ptr();}
506  bool is_empty() const {return string_is_empty_t(get_ptr());}
507  t_size length() const {return strlen_t(get_ptr());}
508 
509  void convert(const wchar_t * p_source,t_size p_source_size = ~0) {m_buffer.convert(codepage_system,p_source,p_source_size);}
510 
511  private:
512  string_codepage_from_wide m_buffer;
513  };
514 
515 #ifdef UNICODE
519 #else
523 #endif
524 
526  public:
527  template<typename t_source> string_utf8_from_os_ex(const t_source * source, t_size sourceLen = ~0) {
528  convert(source,sourceLen);
529  }
530 
531  void convert(const char * source, t_size sourceLen = ~0) {
532  m_buffer = string_utf8_from_ansi(source,sourceLen);
533  }
534  void convert(const wchar_t * source, t_size sourceLen = ~0) {
535  m_buffer = string_utf8_from_wide(source,sourceLen);
536  }
537 
538  operator const char * () const {return get_ptr();}
539  const char * get_ptr() const {return m_buffer.get_ptr();}
540  bool is_empty() const {return m_buffer.is_empty();}
541  t_size length() const {return m_buffer.length();}
542  const char * toString() const {return get_ptr();}
543  private:
545  };
546  }
547 
548 #else
549  namespace stringcvt {
554  }
555 #endif
556 };
557 
558 inline pfc::string_base & operator<<(pfc::string_base & p_fmt, const wchar_t * p_str) { p_fmt.add_string(pfc::stringcvt::string_utf8_from_wide(p_str) ); return p_fmt; }
string_ansi_from_utf8(const string_ansi_from_utf8 &p_source)
Definition: string_conv.h:470
string_codepage_from_utf8(const string_codepage_from_utf8 &p_source)
Definition: string_conv.h:407
pfc::array_t< t_char, t_alloc > m_buffer
Definition: string_conv.h:89
const t_item * get_ptr() const
Definition: array.h:213
char_buffer_t< wchar_t, t_alloc > m_buffer
Definition: string_conv.h:182
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_utf8_to_wide(const char *p_in)
void convert(const char *p_source, t_size p_source_size)
Definition: string_conv.h:122
char_buffer_t< wchar_t, t_alloc > m_buffer
Definition: string_conv.h:376
void convert(unsigned p_codepage, const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:364
t_size estimate_wide_to_ansi(const wchar_t *p_source, t_size p_source_size)
Estimates buffer size required to convert specified wide character string to system codepage...
Definition: string_conv.h:352
string_utf8_from_ansi(const string_utf8_from_ansi &p_source)
Definition: string_conv.h:454
void append(const char *p_source, t_size p_source_size)
Definition: string_conv.h:137
char_buffer_t< char, t_alloc > m_buffer
Definition: string_conv.h:400
void convert(const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:477
t_size convert_wide_to_ansi(char *p_out, t_size p_out_size, const wchar_t *p_source, t_size p_source_size)
Converts string from wide character to system codepage.
Definition: string_conv.h:344
string_wide_from_utf8_t(const char *p_source)
Definition: string_conv.h:119
virtual void add_string(const char *p_string, t_size p_length=~0)=0
void convert(const char *source, t_size sourceLen=~0)
Definition: string_conv.h:531
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...
string_win1252_from_wide_t string_win1252_from_wide
Definition: string_conv.h:207
string_win1252_from_utf8_t(const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:237
string_utf8_from_win1252_t(const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:214
const char * null_string_t< char >()
Definition: string_conv.h:64
string_wide_from_win1252_t(const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:168
string_wide_from_codepage_t(const string_wide_from_codepage_t< t_alloc > &p_source)
Definition: string_conv.h:361
string_utf8_from_codepage(unsigned p_codepage, const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:431
string_ansi_from_wide(const wchar_t *p_source, t_size p_source_size=~0)
Definition: string_conv.h:503
const t_char * get_ptr() const
Definition: string_conv.h:85
string_wide_from_utf8_t string_wide_from_utf8
Definition: string_conv.h:160
string_utf8_from_win1252_t string_utf8_from_win1252
Definition: string_conv.h:230
bool string_is_empty_t(const t_char *p_string, t_size p_string_size=~0)
Definition: string_conv.h:74
string_ansi_from_wide(const string_ansi_from_wide &p_source)
Definition: string_conv.h:502
string_wide_from_utf8_t(const char *p_source, t_size p_source_size)
Definition: string_conv.h:120
char_buffer_t< char, t_alloc > m_buffer
Definition: string_conv.h:251
string_utf8_from_win1252 string_utf8_from_ansi
Definition: string_conv.h:553
t_size estimate_size(const char *source, t_size sourceLen)
Definition: string_conv.h:152
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.
void append(const char *p_source)
Definition: string_conv.h:143
void convert(unsigned p_codepage, const wchar_t *p_source, t_size p_source_size=~0)
Definition: string_conv.h:388
t_size convert_utf8_to_win1252(char *p_out, t_size p_out_size, const char *p_in, t_size p_in_size)
string_codepage_from_utf8 m_buffer
Definition: string_conv.h:480
t_size convert_ansi_to_wide(wchar_t *p_out, t_size p_out_size, const char *p_source, t_size p_source_size)
Converts string from system codepage to wide character.
Definition: string_conv.h:326
t_size estimate_utf8_to_ascii(const char *p_source, t_size p_source_size)
string_codepage_from_utf8(unsigned p_codepage, const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:408
string_wide_from_codepage_t string_wide_from_codepage
Definition: string_conv.h:378
string_utf8_from_wide string_utf8_from_os
Definition: string_conv.h:517
void convert(unsigned p_codepage, const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:433
t_size estimate_win1252_to_wide(const char *p_source, t_size p_source_size)
char_buffer_t< char, t_alloc > m_buffer
Definition: string_conv.h:111
string_codepage_from_wide_t(unsigned p_codepage, const wchar_t *p_source, t_size p_source_size=~0)
Definition: string_conv.h:386
string_utf8_from_ansi(const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:455
void convert(const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:239
string_utf8_from_wide_t string_utf8_from_wide
Definition: string_conv.h:113
char_buffer_t< char, pfc::alloc_fast_aggressive > m_buffer
Definition: string_conv.h:272
t_size strlen_max(const char *ptr, t_size max)
Definition: string_base.h:91
void convert(const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:216
t_size convert_win1252_to_utf8(char *p_out, t_size p_out_size, const char *p_in, t_size p_in_size)
string_codepage_from_wide_t string_codepage_from_wide
Definition: string_conv.h:402
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.
string_codepage_from_wide_t(const string_codepage_from_wide_t< t_alloc > &p_source)
Definition: string_conv.h:385
string_win1252_from_utf8_t string_win1252_from_utf8
Definition: string_conv.h:253
t_size estimate_size(const char *source)
Definition: string_conv.h:155
t_size estimate_utf8_to_wide_quick(t_size sourceLen)
estimate_utf8_to_wide_quick() functions use simple math to determine buffer size required for the con...
Definition: string_conv.h:52
t_size convert_win1252_to_wide(wchar_t *p_out, t_size p_out_size, const char *p_in, t_size p_in_size)
void set_size(t_size p_size)
Definition: array.h:104
string_win1252_from_wide string_ansi_from_wide
Definition: string_conv.h:550
t_size convert_utf8_to_wide_unchecked(wchar_t *p_out, const char *p_in)
const wchar_t * get_ptr() const
Definition: string_conv.h:133
char_buffer_t< char, t_alloc > m_buffer
Definition: string_conv.h:228
void convert(const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:260
string_codepage_from_wide m_buffer
Definition: string_conv.h:512
const t_char * null_string_t()
void convert(unsigned p_codepage, const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:410
void convert(const wchar_t *p_source, t_size p_source_size=~0)
Definition: string_conv.h:98
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.
const wchar_t * null_string_t< wchar_t >()
Definition: string_conv.h:65
t_size convert_utf8_to_ascii(char *p_out, t_size p_out_size, const char *p_in, t_size p_in_size)
string_wide_from_utf8 string_os_from_utf8
Definition: string_conv.h:516
string_ascii_from_utf8(const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:258
t_size estimate_utf8_to_win1252(const char *p_in, t_size p_in_size)
string_wide_from_ansi(const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:487
string_win1252_from_utf8 string_ansi_from_utf8
Definition: string_conv.h:552
string_wide_from_win1252 string_wide_from_ansi
Definition: string_conv.h:551
string_utf8_from_os_ex(const t_source *source, t_size sourceLen=~0)
Definition: string_conv.h:527
string_ansi_from_utf8(const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:471
string_wide_from_codepage m_buffer
Definition: string_conv.h:496
char_buffer_t(const char_buffer_t &p_source)
Definition: string_conv.h:82
void convert(const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:461
t_size convert_wide_to_win1252(char *p_out, t_size p_out_size, const wchar_t *p_in, t_size p_in_size)
string_utf8_from_wide_t(const wchar_t *p_source, t_size p_source_size=~0)
Definition: string_conv.h:96
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...
void convert(const wchar_t *p_source, t_size p_source_size=~0)
Definition: string_conv.h:509
char_buffer_t< wchar_t, t_alloc > m_buffer
Definition: string_conv.h:158
t_size estimate_win1252_to_utf8(const char *p_in, t_size p_in_size)
string_wide_from_codepage_t(unsigned p_codepage, const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:362
void convert(const wchar_t *source, t_size sourceLen=~0)
Definition: string_conv.h:534
string_wide_from_ansi(const string_wide_from_ansi &p_source)
Definition: string_conv.h:486
t_size strlen_t(const t_char *p_string, t_size p_string_size=~0)
Definition: string_conv.h:67
void set_size(t_size p_count)
Definition: string_conv.h:83
t_size estimate_ansi_to_wide(const char *p_source, t_size p_source_size)
Estimates buffer size required to convert specified system codepage string to wide character...
Definition: string_conv.h:334
void convert(const wchar_t *p_source, t_size p_source_size=~0)
Definition: string_conv.h:193
string_utf8_from_codepage m_buffer
Definition: string_conv.h:464
void convert(const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:493
string_utf8_from_codepage(const string_utf8_from_codepage &p_source)
Definition: string_conv.h:430
string_win1252_from_wide_t(const wchar_t *p_source, t_size p_source_size=~0)
Definition: string_conv.h:191
string_wide_from_win1252_t string_wide_from_win1252
Definition: string_conv.h:184
pfc::string_base & operator<<(pfc::string_base &p_fmt, const wchar_t *p_str)
Definition: string_conv.h:558
void convert(const char *p_source)
Definition: string_conv.h:127
t_size get_size() const
Definition: array.h:130
void convert(const char *p_source, t_size p_source_size=~0)
Definition: string_conv.h:170
char_buffer_t< char, t_alloc > m_buffer
Definition: string_conv.h:205
string_wide_from_utf8_fast string_os_from_utf8_fast
Definition: string_conv.h:518
const wchar_t * get_ptr() const
Definition: string_conv.h:489
string_wide_from_utf8_t< alloc_fast_aggressive > string_wide_from_utf8_fast
Definition: string_conv.h:161