nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7aa367c
)
lib/string_ext/utf8: to_cstring will work on UTF-8 strings now.
author
Lucas Bajolet
<r4pass@hotmail.com>
Mon, 21 Jul 2014 16:03:12 +0000
(12:03 -0400)
committer
Lucas Bajolet
<r4pass@hotmail.com>
Tue, 29 Jul 2014 16:00:11 +0000
(12:00 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
lib/string_experimentations/utf8.nit
patch
|
blob
|
history
diff --git
a/lib/string_experimentations/utf8.nit
b/lib/string_experimentations/utf8.nit
index
629793c
..
dc177ca
100644
(file)
--- a/
lib/string_experimentations/utf8.nit
+++ b/
lib/string_experimentations/utf8.nit
@@
-159,6
+159,16
@@
redef class FlatString
self.bytelen = bytelen
end
+ redef fun to_cstring
+ do
+ if real_items != null then return real_items.as(not null)
+ var new_items = calloc_string(bytelen + 1)
+ self.items.copy_to(new_items, bytelen, index[index_from].pos, 0)
+ new_items[bytelen] = '\0'
+ self.real_items = new_items
+ return new_items
+ end
+
redef fun substring(from, count)
do
assert count >= 0