Panda3D
textEncoder.I
1 // Filename: textEncoder.I
2 // Created by: drose (26Mar03)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: TextEncoder::Constructor
18 // Access: Published
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE TextEncoder::
22 TextEncoder() {
23  _encoding = _default_encoding;
24 
25  // Initially, since the text string is empty, we know that both
26  // _text and _wtext accurately reflect the empty state; so we "got"
27  // both of them.
28  _flags = (F_got_text | F_got_wtext);
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: TextEncoder::Copy Constructor
33 // Access: Published
34 // Description:
35 ////////////////////////////////////////////////////////////////////
36 INLINE TextEncoder::
37 TextEncoder(const TextEncoder &copy) :
38  _flags(copy._flags),
39  _encoding(copy._encoding),
40  _text(copy._text),
41  _wtext(copy._wtext)
42 {
43 }
44 
45 ////////////////////////////////////////////////////////////////////
46 // Function: TextEncoder::set_encoding
47 // Access: Published
48 // Description: Specifies how the string set via set_text() is to be
49 // interpreted. The default, E_iso8859, means a
50 // standard string with one-byte characters
51 // (i.e. ASCII). Other encodings are possible to take
52 // advantage of character sets with more than 256
53 // characters.
54 //
55 // This affects only future calls to set_text(); it does
56 // not change text that was set previously.
57 ////////////////////////////////////////////////////////////////////
58 INLINE void TextEncoder::
59 set_encoding(TextEncoder::Encoding encoding) {
60  // Force the previously-set strings to be encoded or decoded now.
61  get_text();
62  get_wtext();
63  _encoding = encoding;
64 }
65 
66 ////////////////////////////////////////////////////////////////////
67 // Function: TextEncoder::get_encoding
68 // Access: Published
69 // Description: Returns the encoding by which the string set via
70 // set_text() is to be interpreted. See set_encoding().
71 ////////////////////////////////////////////////////////////////////
72 INLINE TextEncoder::Encoding TextEncoder::
73 get_encoding() const {
74  return _encoding;
75 }
76 
77 ////////////////////////////////////////////////////////////////////
78 // Function: TextEncoder::set_default_encoding
79 // Access: Published, Static
80 // Description: Specifies the default encoding to be used for all
81 // subsequently created TextEncoder objects. See
82 // set_encoding().
83 ////////////////////////////////////////////////////////////////////
84 INLINE void TextEncoder::
85 set_default_encoding(TextEncoder::Encoding encoding) {
86  _default_encoding = encoding;
87 }
88 
89 ////////////////////////////////////////////////////////////////////
90 // Function: TextEncoder::get_default_encoding
91 // Access: Published, Static
92 // Description: Specifies the default encoding to be used for all
93 // subsequently created TextEncoder objects. See
94 // set_encoding().
95 ////////////////////////////////////////////////////////////////////
96 INLINE TextEncoder::Encoding TextEncoder::
98  return _default_encoding;
99 }
100 
101 ////////////////////////////////////////////////////////////////////
102 // Function: TextEncoder::set_text
103 // Access: Published
104 // Description: Changes the text that is stored in the encoder. The
105 // text should be encoded according to the method
106 // indicated by set_encoding(). Subsequent calls to
107 // get_text() will return this same string, while
108 // get_wtext() will return the decoded version of the
109 // string.
110 ////////////////////////////////////////////////////////////////////
111 INLINE void TextEncoder::
112 set_text(const string &text) {
113  if (!has_text() || _text != text) {
114  _text = text;
115  _flags = (_flags | F_got_text) & ~F_got_wtext;
116  }
117 }
118 
119 ////////////////////////////////////////////////////////////////////
120 // Function: TextEncoder::set_text
121 // Access: Published
122 // Description: The two-parameter version of set_text() accepts an
123 // explicit encoding; the text is immediately decoded
124 // and stored as a wide-character string. Subsequent
125 // calls to get_text() will return the same text
126 // re-encoded using whichever encoding is specified by
127 // set_encoding().
128 ////////////////////////////////////////////////////////////////////
129 INLINE void TextEncoder::
130 set_text(const string &text, TextEncoder::Encoding encoding) {
131  set_wtext(decode_text(text, encoding));
132 }
133 
134 ////////////////////////////////////////////////////////////////////
135 // Function: TextEncoder::clear_text
136 // Access: Published
137 // Description: Removes the text from the TextEncoder.
138 ////////////////////////////////////////////////////////////////////
139 INLINE void TextEncoder::
141  _text = string();
142  _wtext = wstring();
143  _flags |= (F_got_text | F_got_wtext);
144 }
145 
146 ////////////////////////////////////////////////////////////////////
147 // Function: TextEncoder::has_text
148 // Access: Published
149 // Description:
150 ////////////////////////////////////////////////////////////////////
151 INLINE bool TextEncoder::
152 has_text() const {
153  if (_flags & F_got_wtext) {
154  return !_wtext.empty();
155  } else {
156  return !_text.empty();
157  }
158 }
159 
160 ////////////////////////////////////////////////////////////////////
161 // Function: TextEncoder::get_text
162 // Access: Published
163 // Description: Returns the current text, as encoded via the current
164 // encoding system.
165 ////////////////////////////////////////////////////////////////////
166 INLINE string TextEncoder::
167 get_text() const {
168  if ((_flags & F_got_text) == 0) {
169  ((TextEncoder *)this)->_text = encode_wtext(_wtext);
170  ((TextEncoder *)this)->_flags |= F_got_text;
171  }
172  return _text;
173 }
174 
175 ////////////////////////////////////////////////////////////////////
176 // Function: TextEncoder::get_text
177 // Access: Published
178 // Description: Returns the current text, as encoded via the indicated
179 // encoding system.
180 ////////////////////////////////////////////////////////////////////
181 INLINE string TextEncoder::
182 get_text(TextEncoder::Encoding encoding) const {
183  return encode_wtext(get_wtext(), encoding);
184 }
185 
186 ////////////////////////////////////////////////////////////////////
187 // Function: TextEncoder::append_text
188 // Access: Published
189 // Description: Appends the indicates string to the end of the stored
190 // text.
191 ////////////////////////////////////////////////////////////////////
192 INLINE void TextEncoder::
193 append_text(const string &text) {
194  _text = get_text() + text;
195  _flags = (_flags | F_got_text) & ~F_got_wtext;
196 }
197 
198 ////////////////////////////////////////////////////////////////////
199 // Function: TextEncoder::append_unicode_char
200 // Access: Published
201 // Description: Appends a single character to the end of the stored
202 // text. This may be a wide character, up to 16 bits in
203 // Unicode.
204 ////////////////////////////////////////////////////////////////////
205 INLINE void TextEncoder::
206 append_unicode_char(int character) {
207  _wtext = get_wtext() + wstring(1, (wchar_t)character);
208  _flags = (_flags | F_got_wtext) & ~F_got_text;
209 }
210 
211 ////////////////////////////////////////////////////////////////////
212 // Function: TextEncoder::get_num_chars
213 // Access: Published
214 // Description: Returns the number of characters in the stored text.
215 // This is a count of wide characters, after the string
216 // has been decoded according to set_encoding().
217 ////////////////////////////////////////////////////////////////////
218 INLINE int TextEncoder::
219 get_num_chars() const {
220  return get_wtext().length();
221 }
222 
223 ////////////////////////////////////////////////////////////////////
224 // Function: TextEncoder::get_unicode_char
225 // Access: Published
226 // Description: Returns the Unicode value of the nth character in the
227 // stored text. This may be a wide character (greater
228 // than 255), after the string has been decoded
229 // according to set_encoding().
230 ////////////////////////////////////////////////////////////////////
231 INLINE int TextEncoder::
232 get_unicode_char(int index) const {
233  get_wtext();
234  if (index >= 0 && index < (int)_wtext.length()) {
235  return _wtext[index];
236  }
237  return 0;
238 }
239 
240 ////////////////////////////////////////////////////////////////////
241 // Function: TextEncoder::set_unicode_char
242 // Access: Published
243 // Description: Sets the Unicode value of the nth character in the
244 // stored text. This may be a wide character (greater
245 // than 255), after the string has been decoded
246 // according to set_encoding().
247 ////////////////////////////////////////////////////////////////////
248 INLINE void TextEncoder::
249 set_unicode_char(int index, int character) {
250  get_wtext();
251  if (index >= 0 && index < (int)_wtext.length()) {
252  _wtext[index] = character;
253  _flags &= ~F_got_text;
254  }
255 }
256 
257 ////////////////////////////////////////////////////////////////////
258 // Function: TextEncoder::get_encoded_char
259 // Access: Published
260 // Description: Returns the nth char of the stored text, as a one-,
261 // two-, or three-byte encoded string.
262 ////////////////////////////////////////////////////////////////////
263 INLINE string TextEncoder::
264 get_encoded_char(int index) const {
265  return get_encoded_char(index, get_encoding());
266 }
267 
268 ////////////////////////////////////////////////////////////////////
269 // Function: TextEncoder::get_encoded_char
270 // Access: Published
271 // Description: Returns the nth char of the stored text, as a one-,
272 // two-, or three-byte encoded string.
273 ////////////////////////////////////////////////////////////////////
274 INLINE string TextEncoder::
275 get_encoded_char(int index, TextEncoder::Encoding encoding) const {
276  wstring wch(1, (wchar_t)get_unicode_char(index));
277  return encode_wtext(wch, encoding);
278 }
279 
280 ////////////////////////////////////////////////////////////////////
281 // Function: TextEncoder::get_text_as_ascii
282 // Access: Published
283 // Description: Returns the text associated with the node, converted
284 // as nearly as possible to a fully-ASCII
285 // representation. This means replacing accented
286 // letters with their unaccented ASCII equivalents.
287 //
288 // It is possible that some characters in the string
289 // cannot be converted to ASCII. (The string may
290 // involve symbols like the copyright symbol, for
291 // instance, or it might involve letters in some other
292 // alphabet such as Greek or Cyrillic, or even Latin
293 // letters like thorn or eth that are not part of the
294 // ASCII character set.) In this case, as much of the
295 // string as possible will be converted to ASCII, and
296 // the nonconvertible characters will remain encoded in
297 // the encoding specified by set_encoding().
298 ////////////////////////////////////////////////////////////////////
299 INLINE string TextEncoder::
302 }
303 
304 ////////////////////////////////////////////////////////////////////
305 // Function: TextEncoder::reencode_text
306 // Access: Published, Static
307 // Description: Given the indicated text string, which is assumed to
308 // be encoded via the encoding "from", decodes it and
309 // then reencodes it into the encoding "to", and returns
310 // the newly encoded string. This does not change or
311 // affect any properties on the TextEncoder itself.
312 ////////////////////////////////////////////////////////////////////
313 INLINE string TextEncoder::
314 reencode_text(const string &text, TextEncoder::Encoding from,
315  TextEncoder::Encoding to) {
316  return encode_wtext(decode_text(text, from), to);
317 }
318 
319 ////////////////////////////////////////////////////////////////////
320 // Function: TextEncoder::unicode_isalpha
321 // Access: Published, Static
322 // Description: Returns true if the indicated character is an
323 // alphabetic letter, false otherwise. This is akin to
324 // ctype's isalpha(), extended to Unicode.
325 ////////////////////////////////////////////////////////////////////
326 INLINE bool TextEncoder::
327 unicode_isalpha(int character) {
328  const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character);
329  if (entry == (const UnicodeLatinMap::Entry *)NULL) {
330  return false;
331  }
332  return entry->_char_type == UnicodeLatinMap::CT_upper ||
333  entry->_char_type == UnicodeLatinMap::CT_lower;
334 }
335 
336 ////////////////////////////////////////////////////////////////////
337 // Function: TextEncoder::unicode_isdigit
338 // Access: Published, Static
339 // Description: Returns true if the indicated character is a
340 // numeric digit, false otherwise. This is akin to
341 // ctype's isdigit(), extended to Unicode.
342 ////////////////////////////////////////////////////////////////////
343 INLINE bool TextEncoder::
344 unicode_isdigit(int character) {
345  const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character);
346  if (entry == (const UnicodeLatinMap::Entry *)NULL) {
347  // The digits aren't actually listed in the map.
348  return (character >= '0' && character <= '9');
349  }
350  // This silly test (!= 0) is necessary to prevent a VC++ warning.
351  return (isdigit(entry->_ascii_equiv) != 0);
352 }
353 
354 ////////////////////////////////////////////////////////////////////
355 // Function: TextEncoder::unicode_ispunct
356 // Access: Published, Static
357 // Description: Returns true if the indicated character is a
358 // punctuation mark, false otherwise. This is akin to
359 // ctype's ispunct(), extended to Unicode.
360 ////////////////////////////////////////////////////////////////////
361 INLINE bool TextEncoder::
362 unicode_ispunct(int character) {
363  const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character);
364  if (entry == (const UnicodeLatinMap::Entry *)NULL) {
365  // Some punctuation marks aren't listed in the map.
366  return (character >= 0 && character < 128 && ispunct(character));
367  }
368  return entry->_char_type == UnicodeLatinMap::CT_punct;
369 }
370 
371 ////////////////////////////////////////////////////////////////////
372 // Function: TextEncoder::unicode_isupper
373 // Access: Published, Static
374 // Description: Returns true if the indicated character is an
375 // uppercase letter, false otherwise. This is akin to
376 // ctype's isupper(), extended to Unicode.
377 ////////////////////////////////////////////////////////////////////
378 INLINE bool TextEncoder::
379 unicode_isupper(int character) {
380  const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character);
381  if (entry == (const UnicodeLatinMap::Entry *)NULL) {
382  return false;
383  }
384  return entry->_char_type == UnicodeLatinMap::CT_upper;
385 }
386 
387 ////////////////////////////////////////////////////////////////////
388 // Function: TextEncoder::unicode_isspace
389 // Access: Published, Static
390 // Description: Returns true if the indicated character is a
391 // whitespace letter, false otherwise. This is akin to
392 // ctype's isspace(), extended to Unicode.
393 ////////////////////////////////////////////////////////////////////
394 INLINE bool TextEncoder::
395 unicode_isspace(int character) {
396  switch (character) {
397  case ' ':
398  case '\t':
399  case '\n':
400  return true;
401 
402  default:
403  return false;
404  }
405 }
406 
407 ////////////////////////////////////////////////////////////////////
408 // Function: TextEncoder::unicode_islower
409 // Access: Published, Static
410 // Description: Returns true if the indicated character is a
411 // lowercase letter, false otherwise. This is akin to
412 // ctype's islower(), extended to Unicode.
413 ////////////////////////////////////////////////////////////////////
414 INLINE bool TextEncoder::
415 unicode_islower(int character) {
416  const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character);
417  if (entry == (const UnicodeLatinMap::Entry *)NULL) {
418  return false;
419  }
420  return entry->_char_type == UnicodeLatinMap::CT_lower;
421 }
422 
423 ////////////////////////////////////////////////////////////////////
424 // Function: TextEncoder::unicode_toupper
425 // Access: Published, Static
426 // Description: Returns the uppercase equivalent of the given Unicode
427 // character. This is akin to ctype's toupper(),
428 // extended to Unicode.
429 ////////////////////////////////////////////////////////////////////
430 INLINE int TextEncoder::
431 unicode_toupper(int character) {
432  const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character);
433  if (entry == (const UnicodeLatinMap::Entry *)NULL) {
434  return character;
435  }
436  return entry->_toupper_character;
437 }
438 
439 ////////////////////////////////////////////////////////////////////
440 // Function: TextEncoder::unicode_tolower
441 // Access: Published, Static
442 // Description: Returns the uppercase equivalent of the given Unicode
443 // character. This is akin to ctype's tolower(),
444 // extended to Unicode.
445 ////////////////////////////////////////////////////////////////////
446 INLINE int TextEncoder::
447 unicode_tolower(int character) {
448  const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character);
449  if (entry == (const UnicodeLatinMap::Entry *)NULL) {
450  return character;
451  }
452  return entry->_tolower_character;
453 }
454 
455 ////////////////////////////////////////////////////////////////////
456 // Function: TextEncoder::upper
457 // Access: Published, Static
458 // Description: Converts the string to uppercase, assuming the string
459 // is encoded in the default encoding.
460 ////////////////////////////////////////////////////////////////////
461 INLINE string TextEncoder::
462 upper(const string &source) {
463  return upper(source, get_default_encoding());
464 }
465 
466 ////////////////////////////////////////////////////////////////////
467 // Function: TextEncoder::upper
468 // Access: Published, Static
469 // Description: Converts the string to uppercase, assuming the string
470 // is encoded in the indicated encoding.
471 ////////////////////////////////////////////////////////////////////
472 INLINE string TextEncoder::
473 upper(const string &source, TextEncoder::Encoding encoding) {
474  TextEncoder encoder;
475  encoder.set_encoding(encoding);
476  encoder.set_text(source);
477  encoder.make_upper();
478  return encoder.get_text();
479 }
480 
481 ////////////////////////////////////////////////////////////////////
482 // Function: TextEncoder::lower
483 // Access: Published, Static
484 // Description: Converts the string to lowercase, assuming the string
485 // is encoded in the default encoding.
486 ////////////////////////////////////////////////////////////////////
487 INLINE string TextEncoder::
488 lower(const string &source) {
489  return lower(source, get_default_encoding());
490 }
491 
492 ////////////////////////////////////////////////////////////////////
493 // Function: TextEncoder::lower
494 // Access: Published, Static
495 // Description: Converts the string to lowercase, assuming the string
496 // is encoded in the indicated encoding.
497 ////////////////////////////////////////////////////////////////////
498 INLINE string TextEncoder::
499 lower(const string &source, TextEncoder::Encoding encoding) {
500  TextEncoder encoder;
501  encoder.set_encoding(encoding);
502  encoder.set_text(source);
503  encoder.make_lower();
504  return encoder.get_text();
505 }
506 
507 ////////////////////////////////////////////////////////////////////
508 // Function: TextEncoder::set_wtext
509 // Access: Published
510 // Description: Changes the text that is stored in the encoder.
511 // Subsequent calls to get_wtext() will return this same
512 // string, while get_text() will return the encoded
513 // version of the string.
514 ////////////////////////////////////////////////////////////////////
515 INLINE void TextEncoder::
516 set_wtext(const wstring &wtext) {
517  if (!has_text() || _wtext != wtext) {
518  _wtext = wtext;
519  _flags = (_flags | F_got_wtext) & ~F_got_text;
520  }
521 }
522 
523 ////////////////////////////////////////////////////////////////////
524 // Function: TextEncoder::get_wtext
525 // Access: Published
526 // Description: Returns the text associated with the TextEncoder, as
527 // a wide-character string.
528 ////////////////////////////////////////////////////////////////////
529 INLINE const wstring &TextEncoder::
530 get_wtext() const {
531  if ((_flags & F_got_wtext) == 0) {
532  ((TextEncoder *)this)->_wtext = decode_text(_text);
533  ((TextEncoder *)this)->_flags |= F_got_wtext;
534  }
535  return _wtext;
536 }
537 
538 ////////////////////////////////////////////////////////////////////
539 // Function: TextEncoder::append_wtext
540 // Access: Published
541 // Description: Appends the indicates string to the end of the stored
542 // wide-character text.
543 ////////////////////////////////////////////////////////////////////
544 INLINE void TextEncoder::
545 append_wtext(const wstring &wtext) {
546  _wtext = get_wtext() + wtext;
547  _flags = (_flags | F_got_wtext) & ~F_got_text;
548 }
549 
550 ////////////////////////////////////////////////////////////////////
551 // Function: TextEncoder::encode_wtext
552 // Access: Published
553 // Description: Encodes a wide-text string into a single-char string,
554 // according to the current encoding.
555 ////////////////////////////////////////////////////////////////////
556 INLINE string TextEncoder::
557 encode_wtext(const wstring &wtext) const {
558  return encode_wtext(wtext, _encoding);
559 }
560 
561 ////////////////////////////////////////////////////////////////////
562 // Function: TextEncoder::decode_text
563 // Access: Published
564 // Description: Returns the given wstring decoded to a single-byte
565 // string, via the current encoding system.
566 ////////////////////////////////////////////////////////////////////
567 INLINE wstring TextEncoder::
568 decode_text(const string &text) const {
569  return decode_text(text, _encoding);
570 }
571 
572 ////////////////////////////////////////////////////////////////////
573 // Function: wstring ostream operator
574 // Description: Uses the current default encoding to output the
575 // wstring.
576 ////////////////////////////////////////////////////////////////////
577 INLINE ostream &
578 operator << (ostream &out, const wstring &str) {
579  TextEncoder encoder;
580  encoder.set_wtext(str);
581  out << encoder.get_text();
582  return out;
583 }
string get_encoded_char(int index) const
Returns the nth char of the stored text, as a one-, two-, or three-byte encoded string.
Definition: textEncoder.I:264
void append_wtext(const wstring &text)
Appends the indicates string to the end of the stored wide-character text.
Definition: textEncoder.I:545
void append_text(const string &text)
Appends the indicates string to the end of the stored text.
Definition: textEncoder.I:193
int get_num_chars() const
Returns the number of characters in the stored text.
Definition: textEncoder.I:219
static bool unicode_ispunct(int character)
Returns true if the indicated character is a punctuation mark, false otherwise.
Definition: textEncoder.I:362
This class can be used to convert text between multiple representations, e.g.
Definition: textEncoder.h:37
static bool unicode_isspace(int character)
Returns true if the indicated character is a whitespace letter, false otherwise.
Definition: textEncoder.I:395
static Encoding get_default_encoding()
Specifies the default encoding to be used for all subsequently created TextEncoder objects...
Definition: textEncoder.I:97
wstring decode_text(const string &text) const
Returns the given wstring decoded to a single-byte string, via the current encoding system...
Definition: textEncoder.I:568
static string upper(const string &source)
Converts the string to uppercase, assuming the string is encoded in the default encoding.
Definition: textEncoder.I:462
void make_lower()
Adjusts the text stored within the encoder to all lowercase letters (preserving accent marks correctl...
Definition: textEncoder.cxx:47
static bool unicode_isdigit(int character)
Returns true if the indicated character is a numeric digit, false otherwise.
Definition: textEncoder.I:344
void clear_text()
Removes the text from the TextEncoder.
Definition: textEncoder.I:140
static int unicode_tolower(int character)
Returns the uppercase equivalent of the given Unicode character.
Definition: textEncoder.I:447
static bool unicode_islower(int character)
Returns true if the indicated character is a lowercase letter, false otherwise.
Definition: textEncoder.I:415
string get_text_as_ascii() const
Returns the text associated with the node, converted as nearly as possible to a fully-ASCII represent...
Definition: textEncoder.I:300
const wstring & get_wtext() const
Returns the text associated with the TextEncoder, as a wide-character string.
Definition: textEncoder.I:530
void append_unicode_char(int character)
Appends a single character to the end of the stored text.
Definition: textEncoder.I:206
string encode_wtext(const wstring &wtext) const
Encodes a wide-text string into a single-char string, according to the current encoding.
Definition: textEncoder.I:557
static bool unicode_isupper(int character)
Returns true if the indicated character is an uppercase letter, false otherwise.
Definition: textEncoder.I:379
static string reencode_text(const string &text, Encoding from, Encoding to)
Given the indicated text string, which is assumed to be encoded via the encoding "from", decodes it and then reencodes it into the encoding "to", and returns the newly encoded string.
Definition: textEncoder.I:314
int get_unicode_char(int index) const
Returns the Unicode value of the nth character in the stored text.
Definition: textEncoder.I:232
wstring get_wtext_as_ascii() const
Returns the text associated with the node, converted as nearly as possible to a fully-ASCII represent...
Definition: textEncoder.cxx:76
void set_unicode_char(int index, int character)
Sets the Unicode value of the nth character in the stored text.
Definition: textEncoder.I:249
void set_encoding(Encoding encoding)
Specifies how the string set via set_text() is to be interpreted.
Definition: textEncoder.I:59
void set_text(const string &text)
Changes the text that is stored in the encoder.
Definition: textEncoder.I:112
static const Entry * look_up(wchar_t character)
Returns the Entry associated with the indicated character, if there is one.
static string lower(const string &source)
Converts the string to lowercase, assuming the string is encoded in the default encoding.
Definition: textEncoder.I:488
Encoding get_encoding() const
Returns the encoding by which the string set via set_text() is to be interpreted. ...
Definition: textEncoder.I:73
void make_upper()
Adjusts the text stored within the encoder to all uppercase letters (preserving accent marks correctl...
Definition: textEncoder.cxx:30
void set_wtext(const wstring &wtext)
Changes the text that is stored in the encoder.
Definition: textEncoder.I:516
static bool unicode_isalpha(int character)
Returns true if the indicated character is an alphabetic letter, false otherwise. ...
Definition: textEncoder.I:327
static int unicode_toupper(int character)
Returns the uppercase equivalent of the given Unicode character.
Definition: textEncoder.I:431
static void set_default_encoding(Encoding encoding)
Specifies the default encoding to be used for all subsequently created TextEncoder objects...
Definition: textEncoder.I:85
string get_text() const
Returns the current text, as encoded via the current encoding system.
Definition: textEncoder.I:167