ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Utf8.h
Go to the documentation of this file.
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 using namespace std;
11 
12 class Utf8 {
13 private:
19  static int getUnicodeValue(const char *bytes, int size);
20 
21 
22 public:
26  class BadUnicodeException : public exception {
27  virtual const char* what() const throw() {
28  return "Invalid Unicode character encountered";
29  }
30  };
31 
32  //
33  // Instance of BadUnicodeException use to communicate problems.
34  //
36 
40  class BadUtf8CodeException : public exception {
41  virtual const char* what() const throw() {
42  return "Invalid Utf8 sequence encountered";
43  }
44  };
45 
46  //
47  // Instance of BadUtf8CodeException use to communicate problems.
48  //
50 
55  static int getCharSize(int val);
56 
61  static int getUnicodeValue(const char *bytes);
62 
66  static string getUtf8String(int value);
67 
72  static string getPrintableJavaUnicodeCharacter(int value);
73 
77  static string getPrintableJavaUnicodeString(const char *str);
78 };
79 
80 #endif