ROSE  0.9.9.109
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"
11 using namespace std;
12 
13 class ROSE_DLL_API Utf8 {
14 private:
20  static int getUnicodeValue(const char *bytes, int size);
21 
22 
23 public:
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
STL namespace.
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