File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -181,4 +181,24 @@ package body Langkit_Support.Text is
181
181
return Text_Result;
182
182
end Decode ;
183
183
184
+ -- -----------
185
+ -- To_UTF8 --
186
+ -- -----------
187
+
188
+ function To_UTF8
189
+ (Text : Text_Type) return Ada.Strings.UTF_Encoding.UTF_8_String is
190
+ begin
191
+ return Encode (Text, " UTF-8" );
192
+ end To_UTF8 ;
193
+
194
+ -- -------------
195
+ -- From_UTF8 --
196
+ -- -------------
197
+
198
+ function From_UTF8
199
+ (S : Ada.Strings.UTF_Encoding.UTF_8_String) return Text_Type is
200
+ begin
201
+ return Decode (S, " UTF-8" );
202
+ end From_UTF8 ;
203
+
184
204
end Langkit_Support.Text ;
Original file line number Diff line number Diff line change 21
21
-- <http://www.gnu.org/licenses/>. --
22
22
-- ----------------------------------------------------------------------------
23
23
24
+ with Ada.Strings.UTF_Encoding ;
24
25
with Ada.Strings.Wide_Wide_Unbounded ;
25
26
with Ada.Unchecked_Deallocation ;
26
27
@@ -68,6 +69,14 @@ package Langkit_Support.Text is
68
69
function Decode (S : String; Charset : String) return Text_Type;
69
70
-- Likewise, but convert a string to text
70
71
72
+ function To_UTF8
73
+ (Text : Text_Type) return Ada.Strings.UTF_Encoding.UTF_8_String;
74
+ -- Encode the given text into an UTF-8 string
75
+
76
+ function From_UTF8
77
+ (S : Ada.Strings.UTF_Encoding.UTF_8_String) return Text_Type;
78
+ -- Decode the given UTF-8 string into text
79
+
71
80
type Text_Access is access all Text_Type;
72
81
type Text_Cst_Access is access constant Text_Type;
73
82
You can’t perform that action at this time.
0 commit comments