0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / Resource / Resource_Unicode.hxx
CommitLineData
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>
29class 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.
35class Resource_Unicode
36{
37public:
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
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);
57
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);
64
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);
71
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);
78
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);
85
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);
91
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();
97
98 //! Reads converting format from resource "FormatType"
99 //! in Resource Manager "CharSet"
100 Standard_EXPORT static void ReadFormat();
101
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);
107
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);
121
122
123
124
125protected:
126
127
128
129
130
131private:
132
133
134
135
136
137};
138
139
140
141
142
143
144
145#endif // _Resource_Unicode_HeaderFile