42cf5bc1 |
1 | // Created on: 1996-09-26 |
2 | // Created by: Arnaud BOUZY |
3 | // Copyright (c) 1996-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Resource_Unicode_HeaderFile |
18 | #define _Resource_Unicode_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Standard_CString.hxx> |
25 | #include <Standard_Boolean.hxx> |
26 | #include <Standard_PCharacter.hxx> |
27 | #include <Standard_Integer.hxx> |
28 | #include <Resource_FormatType.hxx> |
29 | class TCollection_ExtendedString; |
30 | |
31 | |
32 | //! This class provides functions used to convert a non-ASCII C string |
33 | //! given in ANSI, EUC, GB or SJIS format, to a |
34 | //! Unicode string of extended characters, and vice versa. |
35 | class Resource_Unicode |
36 | { |
37 | public: |
38 | |
39 | DEFINE_STANDARD_ALLOC |
40 | |
41 | |
42 | //! Converts non-ASCII CString <fromstr> in SJIS format |
43 | //! to Unicode ExtendedString <tostr>. |
44 | Standard_EXPORT static void ConvertSJISToUnicode (const Standard_CString fromstr, TCollection_ExtendedString& tostr); |
45 | |
46 | //! Converts non-ASCII CString <fromstr> in EUC format |
47 | //! to Unicode ExtendedString <tostr>. |
48 | Standard_EXPORT static void ConvertEUCToUnicode (const Standard_CString fromstr, TCollection_ExtendedString& tostr); |
49 | |
50 | //! Converts non-ASCII CString <fromstr> in GB format |
51 | //! to Unicode ExtendedString <tostr>. |
52 | Standard_EXPORT static void ConvertGBToUnicode (const Standard_CString fromstr, TCollection_ExtendedString& tostr); |
53 | |
31e026ba |
54 | //! Converts non-ASCII CString <fromstr> in GBK format |
55 | //! to Unicode ExtendedString <tostr>. |
56 | Standard_EXPORT static Standard_Boolean ConvertGBKToUnicode (const Standard_CString fromstr, TCollection_ExtendedString& tostr); |
57 | |
58 | //! Converts non-ASCII CString <fromstr> in Big5 format |
59 | //! to Unicode ExtendedString <tostr>. |
60 | Standard_EXPORT static Standard_Boolean ConvertBig5ToUnicode (const Standard_CString fromstr, TCollection_ExtendedString& tostr); |
61 | |
42cf5bc1 |
62 | //! Converts non-ASCII CString <fromstr> in ANSI format |
63 | //! to Unicode ExtendedString <tostr>. |
64 | Standard_EXPORT static void ConvertANSIToUnicode (const Standard_CString fromstr, TCollection_ExtendedString& tostr); |
65 | |
66 | //! Converts Unicode ExtendedString <fromstr> to non-ASCII |
67 | //! CString <tostr> in SJIS format, limited to <maxsize> |
68 | //! characters. To translate the whole <fromstr>, use more |
69 | //! than twice the length of <fromstr>. Returns true if |
70 | //! <maxsize> has not been reached before end of conversion. |
71 | Standard_EXPORT static Standard_Boolean ConvertUnicodeToSJIS (const TCollection_ExtendedString& fromstr, Standard_PCharacter& tostr, const Standard_Integer maxsize); |
72 | |
73 | //! Converts Unicode ExtendedString <fromstr> to non-ASCII |
74 | //! CString <tostr> in EUC format, limited to <maxsize> |
75 | //! characters. To translate the whole <fromstr>, use more |
76 | //! than twice the length of <fromstr>. Returns true if |
77 | //! <maxsize> has not been reached before end of conversion. |
78 | Standard_EXPORT static Standard_Boolean ConvertUnicodeToEUC (const TCollection_ExtendedString& fromstr, Standard_PCharacter& tostr, const Standard_Integer maxsize); |
79 | |
80 | //! Converts Unicode ExtendedString <fromstr> to non-ASCII |
81 | //! CString <tostr> in GB format, limited to <maxsize> |
82 | //! characters. To translate the whole <fromstr>, use more |
83 | //! than twice the length of <fromstr>. Returns true if |
84 | //! <maxsize> has not been reached before end of conversion. |
85 | Standard_EXPORT static Standard_Boolean ConvertUnicodeToGB (const TCollection_ExtendedString& fromstr, Standard_PCharacter& tostr, const Standard_Integer maxsize); |
86 | |
87 | //! Converts Unicode ExtendedString <fromstr> to non-ASCII |
88 | //! CString <tostr> in ANSI format, limited to <maxsize> |
89 | //! characters. To translate the whole <fromstr>, use more |
90 | //! than twice the length of <fromstr>. Returns true if |
91 | //! <maxsize> has not been reached before end of conversion. |
92 | Standard_EXPORT static Standard_Boolean ConvertUnicodeToANSI (const TCollection_ExtendedString& fromstr, Standard_PCharacter& tostr, const Standard_Integer maxsize); |
93 | |
94 | //! Defines the current conversion format as typecode. |
95 | //! This conversion format will then be used by the |
96 | //! functions ConvertFormatToUnicode and |
97 | //! ConvertUnicodeToFormat to convert the strings. |
98 | Standard_EXPORT static void SetFormat (const Resource_FormatType typecode); |
99 | |
100 | //! Returns the current conversion format (either |
101 | //! ANSI, EUC, GB or SJIS). |
102 | //! The current converting format must be defined in |
103 | //! advance with the SetFormat function. |
104 | Standard_EXPORT static Resource_FormatType GetFormat(); |
105 | |
106 | //! Reads converting format from resource "FormatType" |
107 | //! in Resource Manager "CharSet" |
108 | Standard_EXPORT static void ReadFormat(); |
109 | |
110 | //! Converts the non-ASCII C string fromstr to the |
111 | //! Unicode string of extended characters tostr. |
112 | //! fromstr is translated according to the format |
113 | //! (either ANSI, EUC, GB or SJIS) returned by the function GetFormat. |
114 | Standard_EXPORT static void ConvertFormatToUnicode (const Standard_CString fromstr, TCollection_ExtendedString& tostr); |
115 | |
116 | //! Converts the Unicode string of extended |
117 | //! characters fromstr to the non-ASCII C string |
118 | //! tostr according to the format (either ANSI, EUC, |
119 | //! GB or SJIS) returned by the function GetFormat. |
120 | //! maxsize limits the size of the string tostr to a |
121 | //! maximum number of characters. You need more |
122 | //! than twice the length of the string fromstr to |
123 | //! complete the conversion. |
124 | //! The function returns true if conversion is |
125 | //! complete, i.e. the maximum number of characters |
126 | //! maxsize is not reached by tostr before the end |
127 | //! of conversion of fromstr. |
128 | Standard_EXPORT static Standard_Boolean ConvertUnicodeToFormat (const TCollection_ExtendedString& fromstr, Standard_PCharacter& tostr, const Standard_Integer maxsize); |
129 | |
130 | |
131 | |
132 | |
133 | protected: |
134 | |
135 | |
136 | |
137 | |
138 | |
139 | private: |
140 | |
141 | |
142 | |
143 | |
144 | |
145 | }; |
146 | |
147 | |
148 | |
149 | |
150 | |
151 | |
152 | |
153 | #endif // _Resource_Unicode_HeaderFile |