|
Detailed Description
This module contains all things about encoding.
There are all functions to manipulate the codecvt facet for the encoding.
|
Files |
file | codecvt.hpp |
| codecvt (declaration).
|
file | encoders.hpp |
| Facet access declaration. All function about facet encoding are in this file. We use the libiconv librairie for the encoding.
|
file | error.hpp |
| Declare the error class and macros. Define an encoders::error derived from ximol::error.
|
Classes |
class | codecvt |
| Class codecvt. More...
|
class | error |
| An implementation of a simple error. More...
|
Functions |
XIMOL_BEGIN_NAMESPACE XIMOL_EXPORT
xostream & | operator<< (xostream &xos, const char c) |
XIMOL_EXPORT xostream & | operator<< (xostream &xos, const char *c) |
XIMOL_EXPORT xostream & | operator<< (xostream &xostream_, const std::string &str_) |
XIMOL_EXPORT xostream & | operator<< (xostream &xos, const xchar_t *c) |
XIMOL_TEMPLATE_NULL XIMOL_EXPORT
xostream & | operator<< (xostream &xos, const xstring &c) |
XIMOL_EXPORT xistream & | operator>> (xistream &xis, bool &c) |
XIMOL_ENCODERS_BEGIN_NAMESPACE
XIMOL_EXPORT::std::codecvt<
xchar_t, char, mbstate_t > * | get_ximol_facet (::std::string const &encoding_name) |
| Interface for the ximol_encoders.
|
XIMOL_EXPORT void | place_ximol_facet (::std::codecvt< xchar_t, char, mbstate_t > *placement,::std::string const &encoding_name) |
| place with new placement operator (difficult to use).
|
XIMOL_EXPORT void | change_ximol_facet_encoding (::std::codecvt< xchar_t, char, mbstate_t > *facet,::std::string const &encoding_name) |
| Change encoding on a unique facet.
|
XIMOL_EXPORT void | deep_change (::std::basic_ios< xchar_t > &ios,::std::string const &encoding_name) |
| Change the encoding method for the stream.
|
XIMOL_EXPORT void | prepare_ios (::std::basic_ios< xchar_t > &ios,::std::string const &encoding_name=XIMOL_DEFAULT_ENCODING) |
| prepare ios.
|
XIMOL_EXPORT bool | test_ios (::std::basic_ios< xchar_t > &ios) |
| test ios.
|
Function Documentation
XIMOL_EXPORT void change_ximol_facet_encoding |
( |
::std::codecvt< xchar_t, char, mbstate_t > * |
facet, |
|
|
::std::string const & |
encoding_name |
|
) |
|
|
|
Change encoding on a unique facet.
This function change the encoding on the facet. If the facet is not a ximol facet then an exception is raise. If facet is NULL then nothing is done.
- Exceptions:
-
- Parameters:
-
facet | : the ximol facet |
encoding_name | : the standard encoding name |
- See also:
- use_xml, prepare_ios
Definition at line 98 of file encoders.cpp.
References _(), XIMOL_ENCODERS_AS_ERROR, and XIMOL_ENCODERS_THROW.
Referenced by deep_change(). |
XIMOL_EXPORT void deep_change |
( |
::std::basic_ios< xchar_t > & |
ios, |
|
|
::std::string const & |
encoding_name |
|
) |
|
|
|
Change the encoding method for the stream.
- Warning:
- This function work if the ios have already a ximol facet. If you do not know the nature of the facet, you could use the prepare_ios. The facet will be change.
If there is not any ximol facet then the function raise an exception.
- Exceptions:
-
- Parameters:
-
ios | : the ios in reference |
encoding_name | : the standard encoding name |
- See also:
- use_xml, prepare_ios
Definition at line 115 of file encoders.cpp.
References change_ximol_facet_encoding(), and XIMOL_USE_FACET.
Referenced by xistream::encoding(), and xostream::encoding(). |
XIMOL_ENCODERS_BEGIN_NAMESPACE XIMOL_EXPORT ::std::codecvt<xchar_t, char, mbstate_t>* get_ximol_facet |
( |
::std::string const & |
encoding_name |
) |
|
|
|
Interface for the ximol_encoders.
This interface is based on libiconv 1-8. The memory must be freed. If you use the imbue method with the result, you must not free the memory.
Here is the list of all supported encoding (from the libiconv manual):
- European languages ASCII, ISO-8859-{1,2,3,4,5,7,9,10,13,14,15,16}, KOI8-R, KOI8-U, KOI8-RU, CP{1250,1251,1252,1253,1254,1257}, CP{850,866}, Mac{Roman,CentralEurope,Iceland,Croatian,Romania}, Mac{Cyrillic,Ukraine,Greek,Turkish}, Macintosh
- Semitic languages ISO-8859-{6,8}, CP{1255,1256}, CP862, Mac{Hebrew,Arabic}
- Japanese EUC-JP, SHIFT_JIS, CP932, ISO-2022-JP, ISO-2022-JP-2, ISO-2022-JP-1
- Chinese EUC-CN, HZ, GBK, GB18030, EUC-TW, BIG5, CP950, BIG5-HKSCS, ISO-2022-CN, ISO-2022-CN-EXT
- Korean EUC-KR, CP949, ISO-2022-KR, JOHAB
- Armenian ARMSCII-8
- Georgian Georgian-Academy, Georgian-PS
- Tajik KOI8-T
- Thai TIS-620, CP874, MacThai
- Laotian MuleLao-1, CP1133
- Vietnamese VISCII, TCVN, CP1258
- Platform specifics HP-ROMAN8, NEXTSTEP
- Full Unicode UTF-8 UCS-2, UCS-2BE, UCS-2LE UCS-4, UCS-4BE, UCS-4LE UTF-16, UTF-16BE, UTF-16LE UTF-32, UTF-32BE, UTF-32LE UTF-7 C99, JAVA
- European languages CP{437,737,775,852,853,855,857,858,860,861,863,865,869,1125}
- Semitic languages CP864
- Japanese EUC-JISX0213, Shift_JISX0213, ISO-2022-JP-3
- Turkmen TDS565
- Platform specifics RISCOS-LATIN1
- Parameters:
-
encoding_name | : the encoding name from the list above. |
- Returns:
- ::std::codecvt<xchar_t, char, mbstate_t>* : NULL or the codecvt facet pointer.
Definition at line 82 of file encoders.cpp.
Referenced by prepare_ios(). |
|
redefinition of the put to operator
- Parameters:
-
xos | : the XML ostream |
c | : xstring * to put |
- Returns:
- xostream& : the XML stream in return.
Definition at line 247 of file io.cpp.
References xstring. |
|
redefinition of the put to operator
- Parameters:
-
xos | : the XML ostream |
c | : xchar_t * to put |
- Returns:
- xostream& : the XML stream in return.
Definition at line 237 of file io.cpp.
References xchar_t. |
XIMOL_EXPORT xostream& operator<< |
( |
xostream & |
xostream_, |
|
|
const std::string & |
str_ |
|
) |
|
|
|
redefinition of the put to operator
- Parameters:
-
xos | : the XML ostream |
c | : char * to put |
- Returns:
- xostream& : the XML stream in return.
Definition at line 209 of file io.cpp. |
|
redefinition of the put to operator
- Parameters:
-
xos | : the XML ostream |
c | : char * to put |
- Returns:
- xostream& : the XML stream in return.
Definition at line 197 of file io.cpp.
References xchar_t. |
XIMOL_BEGIN_NAMESPACE XIMOL_EXPORT xostream& operator<< |
( |
xostream & |
xos, |
|
|
const char |
c |
|
) |
|
|
|
redefinition of the put to operator
- Parameters:
-
xos | : the XML ostream |
c | : char to put |
- Returns:
- xostream& : the XML stream in return.
Definition at line 185 of file io.cpp.
References xchar_t. |
|
redefinition of the get from operator
- Parameters:
-
xis | : the XML istream |
c | : xchar_t to get |
- Returns:
- xistream& : the XML stream in return.
Definition at line 278 of file io.cpp. |
XIMOL_EXPORT void place_ximol_facet |
( |
::std::codecvt< xchar_t, char, mbstate_t > * |
placement, |
|
|
::std::string const & |
encoding_name |
|
) |
|
|
|
place with new placement operator (difficult to use).
- Warning:
- This function is only here for expert.
Definition at line 90 of file encoders.cpp. |
XIMOL_EXPORT void prepare_ios |
( |
::std::basic_ios< xchar_t > & |
ios, |
|
|
::std::string const & |
encoding_name = XIMOL_DEFAULT_ENCODING |
|
) |
|
|
|
prepare ios.
put a ximol facet to the ios. This is a low-level function, and you should consider to use the use_xml function.
The default encoding name is "UTF-8". You could change the default encoding name at compile time with the macro XIMOL_DEFAULT_ENCODING.
- Parameters:
-
ios | : the ios in reference |
encoding_name | : the standard encoding name |
- See also:
- use_xml, XIMOL_DEFAULT_ENCODING
Definition at line 130 of file encoders.cpp.
References get_ximol_facet(), and XIMOL_ADD_FACET.
Referenced by AfterBOM(), xfstream::xfstream(), xifstream::xifstream(), xistream::xistream(), xistringstream::xistringstream(), xofstream::xofstream(), xostream::xostream(), xostringstream::xostringstream(), and xstringstream::xstringstream(). |
XIMOL_EXPORT bool test_ios |
( |
::std::basic_ios< xchar_t > & |
ios |
) |
|
|
|
test ios.
Test if the ximol facet is set on the stream. This function is only interessting for test.
In normal condition we have
- Parameters:
-
ios | : the ios in reference. |
- Returns:
- : true if the ximol facet is set and false otherwise.
Definition at line 138 of file encoders.cpp.
References XIMOL_USE_FACET. |
|
|