Gobo Regexp and Unicode support.
"Ted" <kkkkg999-/[email protected]> Fri, 13 Jun 2008 09:53:28 -0000
| Newsgroups | gmane.comp.lang.eiffel.gobo.general |
|---|---|
| Message-ID | <[email protected]> |
I read somewhere Gobo Regexp doesn't support Unicode yet.
After some investigation. I found some minor changes would make it
support Unicode (See following patch).
Can someone confirm? And merge it into the library if possible.
Index: interface/rx_regular_expression.e
===================================================================
--- interface/rx_regular_expression.e (revision 6423)
+++ interface/rx_regular_expression.e (working copy)
@@ -49,12 +49,12 @@
a_string_same_type: ANY_.same_types (a_string, a_replacement)
local
i, j, nb, ref: INTEGER
- c: CHARACTER
+ c: INTEGER
do
nb := a_replacement.count
from i := 1 until i > nb loop
- c := a_replacement.item (i)
- if c = '\' then
+ c := a_replacement.item_code (i)
+ if c = ('\').code then
from
i := i + 1
j := i
@@ -63,13 +63,13 @@
i > nb or else
(a_replacement.item_code (i) < Zero_code or
a_replacement.item_code (i) > Nine_code)
loop
- c := a_replacement.item (i)
- ref := ref * 10 + c.code - Zero_code
+ c := a_replacement.item_code (i)
+ ref := ref * 10 + c - Zero_code
i := i + 1
end
if i <= nb then
- c := a_replacement.item (i)
- if c = '\' then
+ c := a_replacement.item_code (i)
+ if c = ('\').code then
if i > j then
-- Minimal one digit readed,
if ref < match_count then
@@ -77,7 +77,7 @@
end
else
-- Double backslash means one \\ => \.
- a_string.append_character (c)
+ a_string.append_code (c.as_natural_32)
end
i := i + 1
else
@@ -95,7 +95,7 @@
end
else
-- Simply put the character in.
- a_string.append_character (c)
+ a_string.append_code (c.as_natural_32)
i := i + 1
end
end
Index: pcre/rx_pcre_compiler.e
===================================================================
--- pcre/rx_pcre_compiler.e (revision 6423)
+++ pcre/rx_pcre_compiler.e (working copy)
@@ -377,8 +377,7 @@
local
an_option: INTEGER
do
- STRING_.wipe_out (pattern)
- pattern.append_string (a_pattern)
+ pattern := a_pattern.twin
pattern.append_character ('%U')
pattern_count := a_pattern.count
pattern_position := 1
Index: support/rx_byte_code.e
===================================================================
--- support/rx_byte_code.e (revision 6423)
+++ support/rx_byte_code.e (working copy)
@@ -149,9 +149,7 @@
local
c: INTEGER
do
- -- TODO: handle unicode.
- c := a_code \\ 256
- byte_code.put (c, i)
+ byte_code.put (a_code, i)
ensure
character_set: character_item (i) = a_code
end
Regards,
Ted