Fixed code to be compilable with EiffelStudio 6.8 and 7.0 (due to recent change in UNICODE_CONVERSION) UNICODE_CONVERSION

This commit is contained in:
Jocelyn Fiat
2011-10-31 08:42:48 +01:00
parent 812f521c88
commit 6f600362e3
5 changed files with 129 additions and 7 deletions

View File

@@ -15,7 +15,18 @@
<cluster name="src" location="src\" recursive="true">
<file_rule>
<exclude>/tests$</exclude>
<exclude>/spec$</exclude>
</file_rule>
<cluster name="src_before_70" location="$\spec\before_70" recursive="true">
<condition>
<version type="compiler" max="7.0.8.7585"/>
</condition>
</cluster>
<cluster name="src_70" location="$\spec\70" recursive="true">
<condition>
<version type="compiler" min="7.0.8.7586"/>
</condition>
</cluster>
</cluster>
</target>
<target name="tests" extends="encoder">

View File

@@ -15,7 +15,18 @@
<cluster name="src" location="src\" recursive="true">
<file_rule>
<exclude>/tests$</exclude>
<exclude>/spec$</exclude>
</file_rule>
<cluster name="src_before_70" location="$\spec\before_70" recursive="true">
<condition>
<version type="compiler" max="7.0.8.7585"/>
</condition>
</cluster>
<cluster name="src_70" location="$\spec\70" recursive="true">
<condition>
<version type="compiler" min="7.0.8.7586"/>
</condition>
</cluster>
</cluster>
</target>

View File

@@ -0,0 +1,32 @@
note
description : "Objects that ..."
author : "$Author$"
date : "$Date$"
revision : "$Revision$"
deferred class
UTF8_URL_ENCODER_I
inherit
ANY
UNICODE_CONVERSION
export
{NONE} all
{ANY} is_valid_utf8
undefine
is_little_endian
end
note
copyright: "2011-2011, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -0,0 +1,73 @@
note
description : "Objects that ..."
author : "$Author$"
date : "$Date$"
revision : "$Revision$"
deferred class
UTF8_URL_ENCODER_I
inherit
ANY
UNICODE_CONVERSION
export
{NONE} all
undefine
is_little_endian
end
feature -- Status report
is_valid_utf8 (a_string: STRING): BOOLEAN
-- Is `a_string' valid UTF-8 string?
require
a_string_not_void: a_string /= Void
local
l_nat8: NATURAL_8
l_code: NATURAL_32
i, nb, cnt: INTEGER
do
from
i := 1
nb := a_string.count
Result := True
until
i > nb or not Result
loop
l_nat8 := a_string.code (i).to_natural_8
if l_nat8 <= 127 then
-- Form 0xxxxxxx.
elseif (l_nat8 & 0xE0) = 0xC0 then
-- Form 110xxxxx 10xxxxxx.
l_code := (l_nat8 & 0x1F).to_natural_32 |<< 6
i := i + 1
elseif (l_nat8 & 0xF0) = 0xE0 then
-- Form 1110xxxx 10xxxxxx 10xxxxxx.
i := i + 2
elseif (l_nat8 & 0xF8) = 0xF0 then
-- Form 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx.
i := i + 3
elseif (l_nat8 & 0xFC) = 0xF8 then
-- Starts with 111110xx
Result := False
else
-- Starts with 1111110x
Result := False
end
i := i + 1
end
end
note
copyright: "2011-2011, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -21,12 +21,7 @@ inherit
decoded_string
end
UNICODE_CONVERSION
export
{NONE} all
{ANY} is_valid_utf8
undefine
is_little_endian
UTF8_URL_ENCODER_I
redefine
default_create
end
@@ -35,7 +30,7 @@ feature {NONE} -- Initialization
default_create
do
Precursor {UNICODE_CONVERSION}
Precursor {UTF8_URL_ENCODER_I}
end
feature -- Access