File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -164,4 +164,21 @@ package body Langkit_Support.Text is
164
164
From_Code => Text_Charset);
165
165
end Encode ;
166
166
167
+ -- ----------
168
+ -- Decode --
169
+ -- ----------
170
+
171
+ function Decode (S : String; Charset : String) return Text_Type is
172
+ Result : constant String := GNATCOLL.Iconv.Iconv
173
+ (Input => S,
174
+ To_Code => Text_Charset,
175
+ From_Code => Charset);
176
+ pragma Assert (S'Length mod 4 = 0 );
177
+
178
+ Text_Result : constant Text_Type (1 .. Result'Length / 4 )
179
+ with Import, Address => Result'Address;
180
+ begin
181
+ return Text_Result;
182
+ end Decode ;
183
+
167
184
end Langkit_Support.Text ;
Original file line number Diff line number Diff line change @@ -62,9 +62,12 @@ package Langkit_Support.Text is
62
62
function Encode (Text : Text_Type; Charset : String) return String;
63
63
-- Use GNATCOLL.Iconv to convert Text into a String encoded using the given
64
64
-- Charset. Note that this is only a convenience wrapper around
65
- -- GNATCOLL.Iconv: for instance, if performance needs dictatet to avoid
65
+ -- GNATCOLL.Iconv: for instance, if performance needs dictate to avoid
66
66
-- secondary stack usage, please use directly GNATCOLL.Iconv.
67
67
68
+ function Decode (S : String; Charset : String) return Text_Type;
69
+ -- Likewise, but convert a string to text
70
+
68
71
type Text_Access is access all Text_Type;
69
72
type Text_Cst_Access is access constant Text_Type;
70
73
You can’t perform that action at this time.
0 commit comments