ROSE 0.11.145.192
Utf8.h
1#ifndef SAGE3_UTF8__H
2#define SAGE3_UTF8__H
3
4/*
5 * Functions used to convert from Unicode to Utf8 and vice-versa
6 *
7 */
8
9#include <exception>
10#include "rosedll.h"
11using namespace std;
12
13class ROSE_DLL_API Utf8 {
14private:
20 static int getUnicodeValue(const char *bytes, int size);
21
22
23public:
27 class BadUnicodeException : public exception {
28 virtual const char* what() const throw() {
29 return "Invalid Unicode character encountered";
30 }
31 };
32
33 //
34 // Instance of BadUnicodeException use to communicate problems.
35 //
36 static BadUnicodeException bad_unicode_exception;
37
41 class BadUtf8CodeException : public exception {
42 virtual const char* what() const throw() {
43 return "Invalid Utf8 sequence encountered";
44 }
45 };
46
47 //
48 // Instance of BadUtf8CodeException use to communicate problems.
49 //
50 static BadUtf8CodeException bad_utf8_code_exception;
51
56 static int getCharSize(int val);
57
62 static int getUnicodeValue(const char *bytes);
63
67 static string getUtf8String(int value);
68
73 static string getPrintableJavaUnicodeCharacter(int value);
74
78 static string getPrintableJavaUnicodeString(const char *str);
79};
80
81#endif
Class thrown when a Unicode character is encountered.
Definition Utf8.h:27
Class thrown when a bad Utf8 sequence is encountered.
Definition Utf8.h:41
Definition Utf8.h:13
static string getPrintableJavaUnicodeString(const char *str)
Construct a printable unicode string for Java from a given Utf8 string of characters.
static int getUnicodeValue(const char *bytes)
Compute the code value of a Unicode character encoded in UTF8 format in the array of characters "byte...
static string getPrintableJavaUnicodeCharacter(int value)
Convert the Unicode "value" into a printable Unicode character.
static string getUtf8String(int value)
Convert a unicode character into its Utf8 representation.
static int getCharSize(int val)
Compute the number of bytes that was required to store a UTF8 character sequence that starts with the...