use this class to manage strings where the character encoding must be specified and may be different than the actual encoding in the string
More...
#include <QoreString.h>
|
|
DLLLOCAL | TempEncodingHelper () |
| | creates an empty TempEncodingHelperObject that may be initialized with TempEncodingHelper::set() later
|
| |
| DLLLOCAL | TempEncodingHelper (const QoreString &s, const QoreEncoding *qe, ExceptionSink *xsink) |
| | converts the given string to the required encoding if necessary
|
| |
| DLLLOCAL | TempEncodingHelper (const QoreString *s, const QoreEncoding *qe, ExceptionSink *xsink) |
| | converts the given string to the required encoding if necessary
|
| |
|
DLLLOCAL | ~TempEncodingHelper () |
| | deletes any temporary string being managed by the object
|
| |
| DLLLOCAL char * | giveBuffer () |
| | returns a char pointer of the string, the caller owns the pointer returned (it must be manually freed)
|
| |
|
DLLLOCAL bool | is_temp () const |
| | returns true if a temporary string is being managed
|
| |
|
DLLLOCAL void | makeTemp () |
| | ensures that the object is holding a temporary value
|
| |
| DLLLOCAL | operator bool () const |
| | returns false if the object is empty (for example, if a Qore-language exception was thrown in the constructor), true if not
|
| |
|
DLLLOCAL const QoreString * | operator* () |
| | returns the string being managed
|
| |
|
DLLLOCAL const QoreString * | operator-> () |
| | returns the string being managed
|
| |
| DLLEXPORT void | removeBom () |
| | remove any leading byte order marker (BOM) from UTF-16* strings
|
| |
| DLLLOCAL int | set (const QoreString *s, const QoreEncoding *qe, ExceptionSink *xsink) |
| | discards any current state and sets and converts (if necessary) a new string to the desired encoding
|
| |
use this class to manage strings where the character encoding must be specified and may be different than the actual encoding in the string
this class calls QoreString::convertEncoding() if necessary and manages any temporary string created by this call. the destructor will delete any temporary string if necessary. Note that the constructor may add Qore-language exception information to the "xsink" parameter in case character set encoding conversion was necessary and failed
- See also
- QoreString
if (!str)
return 0;
printf("%s\n", utf8_str->getBuffer());
DLLEXPORT const QoreEncoding * QCS_UTF8
UTF-8 multi-byte encoding (only UTF-8 and UTF-16 are multi-byte encodings)
Definition QoreEncoding.h:247
DLLLOCAL TempEncodingHelper(const QoreString &s, const QoreEncoding *qe, ExceptionSink *xsink)
converts the given string to the required encoding if necessary
Definition QoreString.h:1206
◆ TempEncodingHelper() [1/2]
converts the given string to the required encoding if necessary
- Parameters
-
| s | a reference to the QoreString input value |
| qe | the QoreEncoding required |
| xsink | if an error occurs, the Qore-language exception information will be added here |
Referenced by removeBom().
◆ TempEncodingHelper() [2/2]
converts the given string to the required encoding if necessary
- Parameters
-
| s | a pointer to the QoreString input value |
| qe | the QoreEncoding required |
| xsink | if an error occurs, the Qore-language exception information will be added here |
◆ giveBuffer()
| DLLLOCAL char * TempEncodingHelper::giveBuffer |
( |
| ) |
|
|
inline |
returns a char pointer of the string, the caller owns the pointer returned (it must be manually freed)
- Returns
- a char pointer of the string, the caller owns the pointer returned
◆ operator bool()
| DLLLOCAL TempEncodingHelper::operator bool |
( |
| ) |
const |
|
inline |
returns false if the object is empty (for example, if a Qore-language exception was thrown in the constructor), true if not
- Returns
- false if the object is empty, true if not
◆ removeBom()
| DLLEXPORT void TempEncodingHelper::removeBom |
( |
| ) |
|
remove any leading byte order marker (BOM) from UTF-16* strings
- Since
- Qore 0.8.13
References TempEncodingHelper().
◆ set()
discards any current state and sets and converts (if necessary) a new string to the desired encoding
note that the return value is the opposite of most qore functions because it was implemented incorrectly; the documentation has been changed to reflect the incorrect implementation; the implementation was not fixed in order to preserve source compatibility
- Parameters
-
| s | a pointer to the QoreString input value |
| qe | the QoreEncoding required |
| xsink | if an error occurs, the Qore-language exception information will be added here |
- Returns
- 1=OK, 0=an error occurred and a Qore-language exception was raised
The documentation for this class was generated from the following file: