1 -- File: Resource_Unicode.cdl
2 -- Created: Thu Sep 26 14:30:43 1996
3 -- Author: Arnaud BOUZY
4 -- <adn@legox.paris1.matra-dtv.fr>
5 ---Copyright: Matra Datavision 1996
8 class Unicode from Resource
10 ---Purpose: This class provides functions used to convert a non-ASCII C string
11 -- given in ANSI, EUC, GB or SJIS format, to a
12 -- Unicode string of extended characters, and vice versa.
14 uses ExtendedString from TCollection,
15 FormatType from Resource
19 ConvertSJISToUnicode(myclass;
21 tostr : out ExtendedString);
22 ---Purpose: Converts non-ASCII CString <fromstr> in SJIS format
23 -- to Unicode ExtendedString <tostr>.
26 ConvertEUCToUnicode(myclass;
28 tostr : out ExtendedString);
29 ---Purpose: Converts non-ASCII CString <fromstr> in EUC format
30 -- to Unicode ExtendedString <tostr>.
32 ConvertGBToUnicode(myclass;
34 tostr : out ExtendedString);
35 ---Purpose: Converts non-ASCII CString <fromstr> in GB format
36 -- to Unicode ExtendedString <tostr>.
38 ConvertANSIToUnicode(myclass;
40 tostr : out ExtendedString);
41 ---Purpose: Converts non-ASCII CString <fromstr> in ANSI format
42 -- to Unicode ExtendedString <tostr>.
46 ConvertUnicodeToSJIS(myclass;
47 fromstr : ExtendedString;
48 tostr :out PCharacter;
50 ---Purpose: Converts Unicode ExtendedString <fromstr> to non-ASCII
51 -- CString <tostr> in SJIS format, limited to <maxsize>
52 -- characters. To translate the whole <fromstr>, use more
53 -- than twice the length of <fromstr>. Returns true if
54 -- <maxsize> has not been reached before end of conversion.
57 ConvertUnicodeToEUC(myclass;
58 fromstr : ExtendedString;
59 tostr : out PCharacter;
61 ---Purpose: Converts Unicode ExtendedString <fromstr> to non-ASCII
62 -- CString <tostr> in EUC format, limited to <maxsize>
63 -- characters. To translate the whole <fromstr>, use more
64 -- than twice the length of <fromstr>. Returns true if
65 -- <maxsize> has not been reached before end of conversion.
69 ConvertUnicodeToGB(myclass;
70 fromstr : ExtendedString;
71 tostr : out PCharacter;
73 ---Purpose: Converts Unicode ExtendedString <fromstr> to non-ASCII
74 -- CString <tostr> in GB 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.
81 ConvertUnicodeToANSI(myclass;
82 fromstr : ExtendedString;
83 tostr : out PCharacter;
85 ---Purpose: Converts Unicode ExtendedString <fromstr> to non-ASCII
86 -- CString <tostr> in ANSI format, limited to <maxsize>
87 -- characters. To translate the whole <fromstr>, use more
88 -- than twice the length of <fromstr>. Returns true if
89 -- <maxsize> has not been reached before end of conversion.
93 SetFormat(myclass; typecode : FormatType from Resource);
94 ---Purpose: 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.
100 ---Purpose: 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 returns FormatType from Resource;
108 ---Purpose: Reads converting format from resource "FormatType"
109 -- in Resource Manager "CharSet"
111 ConvertFormatToUnicode(myclass;
113 tostr : out ExtendedString);
114 ---Purpose: Converts the non-ASCII C string fromstr to the
115 -- Unicode string of extended characters tostr.
116 -- fromstr is translated according to the format
117 -- (either ANSI, EUC, GB or SJIS) returned by the function GetFormat.
119 ConvertUnicodeToFormat(myclass;
120 fromstr : ExtendedString;
121 tostr : out PCharacter;
123 ---Purpose: Converts the Unicode string of extended
124 -- characters fromstr to the non-ASCII C string
125 -- tostr according to the format (either ANSI, EUC,
126 -- GB or SJIS) returned by the function GetFormat.
127 -- maxsize limits the size of the string tostr to a
128 -- maximum number of characters. You need more
129 -- than twice the length of the string fromstr to
130 -- complete the conversion.
131 -- The function returns true if conversion is
132 -- complete, i.e. the maximum number of characters
133 -- maxsize is not reached by tostr before the end
134 -- of conversion of fromstr.