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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Resource_Unicode_HeaderFile
18 #define _Resource_Unicode_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
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;
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
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);
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);
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);
54 //! Converts non-ASCII CString <fromstr> in ANSI format
55 //! to Unicode ExtendedString <tostr>.
56 Standard_EXPORT static void ConvertANSIToUnicode (const Standard_CString fromstr, TCollection_ExtendedString& tostr);
58 //! Converts Unicode ExtendedString <fromstr> to non-ASCII
59 //! CString <tostr> in SJIS format, limited to <maxsize>
60 //! characters. To translate the whole <fromstr>, use more
61 //! than twice the length of <fromstr>. Returns true if
62 //! <maxsize> has not been reached before end of conversion.
63 Standard_EXPORT static Standard_Boolean ConvertUnicodeToSJIS (const TCollection_ExtendedString& fromstr, Standard_PCharacter& tostr, const Standard_Integer maxsize);
65 //! Converts Unicode ExtendedString <fromstr> to non-ASCII
66 //! CString <tostr> in EUC format, limited to <maxsize>
67 //! characters. To translate the whole <fromstr>, use more
68 //! than twice the length of <fromstr>. Returns true if
69 //! <maxsize> has not been reached before end of conversion.
70 Standard_EXPORT static Standard_Boolean ConvertUnicodeToEUC (const TCollection_ExtendedString& fromstr, Standard_PCharacter& tostr, const Standard_Integer maxsize);
72 //! Converts Unicode ExtendedString <fromstr> to non-ASCII
73 //! CString <tostr> in GB format, limited to <maxsize>
74 //! characters. To translate the whole <fromstr>, use more
75 //! than twice the length of <fromstr>. Returns true if
76 //! <maxsize> has not been reached before end of conversion.
77 Standard_EXPORT static Standard_Boolean ConvertUnicodeToGB (const TCollection_ExtendedString& fromstr, Standard_PCharacter& tostr, const Standard_Integer maxsize);
79 //! Converts Unicode ExtendedString <fromstr> to non-ASCII
80 //! CString <tostr> in ANSI format, limited to <maxsize>
81 //! characters. To translate the whole <fromstr>, use more
82 //! than twice the length of <fromstr>. Returns true if
83 //! <maxsize> has not been reached before end of conversion.
84 Standard_EXPORT static Standard_Boolean ConvertUnicodeToANSI (const TCollection_ExtendedString& fromstr, Standard_PCharacter& tostr, const Standard_Integer maxsize);
86 //! Defines the current conversion format as typecode.
87 //! This conversion format will then be used by the
88 //! functions ConvertFormatToUnicode and
89 //! ConvertUnicodeToFormat to convert the strings.
90 Standard_EXPORT static void SetFormat (const Resource_FormatType typecode);
92 //! Returns the current conversion format (either
93 //! ANSI, EUC, GB or SJIS).
94 //! The current converting format must be defined in
95 //! advance with the SetFormat function.
96 Standard_EXPORT static Resource_FormatType GetFormat();
98 //! Reads converting format from resource "FormatType"
99 //! in Resource Manager "CharSet"
100 Standard_EXPORT static void ReadFormat();
102 //! Converts the non-ASCII C string fromstr to the
103 //! Unicode string of extended characters tostr.
104 //! fromstr is translated according to the format
105 //! (either ANSI, EUC, GB or SJIS) returned by the function GetFormat.
106 Standard_EXPORT static void ConvertFormatToUnicode (const Standard_CString fromstr, TCollection_ExtendedString& tostr);
108 //! Converts the Unicode string of extended
109 //! characters fromstr to the non-ASCII C string
110 //! tostr according to the format (either ANSI, EUC,
111 //! GB or SJIS) returned by the function GetFormat.
112 //! maxsize limits the size of the string tostr to a
113 //! maximum number of characters. You need more
114 //! than twice the length of the string fromstr to
115 //! complete the conversion.
116 //! The function returns true if conversion is
117 //! complete, i.e. the maximum number of characters
118 //! maxsize is not reached by tostr before the end
119 //! of conversion of fromstr.
120 Standard_EXPORT static Standard_Boolean ConvertUnicodeToFormat (const TCollection_ExtendedString& fromstr, Standard_PCharacter& tostr, const Standard_Integer maxsize);
145 #endif // _Resource_Unicode_HeaderFile