note
	description: "[
		Sequences of 8-bit characters, accessible through integer indices
		in a contiguous range. Read-only interface.
	]"
	library: "Free implementation of ELKS library"
	status: "See notice at end of class."
	legal: "See notice at end of class."
	date: "$Date: 2020-05-19 14:32:38 +0000 (Tue, 19 May 2020) $"
	revision: "$Revision: 104260 $"

deferred class 
	READABLE_STRING_8

convert
	to_cil: {SYSTEM_STRING},
	as_string_8: {STRING_8},
	as_readable_string_32: {READABLE_STRING_32},
	as_string_32: {STRING_32}

feature {NONE} -- Initialization

	default_create
			-- Process instances of classes with no creation clause.
			-- (Default: do nothing.)
			-- (from ANY)
		do
		end

	make (n: INTEGER_32)
			-- Allocate space for at least n characters.
		require -- from READABLE_STRING_GENERAL
			non_negative_size: n >= 0
		do
			count := 0
			internal_hash_code := 0
			internal_case_insensitive_hash_code := 0
			create area.make_filled ('%U', n + 1)
		ensure -- from READABLE_STRING_GENERAL
			empty_string: count = 0
			area_allocated: capacity >= n
		end

	make_empty
			-- Create empty string.
			-- (from READABLE_STRING_GENERAL)
		do
			make (0)
		ensure -- from READABLE_STRING_GENERAL
			empty: count = 0
			area_allocated: capacity >= 0
		end

	make_filled (c: CHARACTER_8; n: INTEGER_32)
			-- Create string of length n filled with c.
		require
			valid_count: n >= 0
		do
			make (n)
			fill_character (c)
		ensure
			count_set: count = n
			area_allocated: capacity >= n
			filled: occurrences (c) = count
		end

	make_from_c (c_string: POINTER)
			-- Initialize from contents of c_string,
			-- a string created by some C function.
		require
			c_string_exists: c_string /= default_pointer
		local
			l_count: INTEGER_32
		do
			C_string_provider.set_shared_from_pointer (c_string)
			l_count := C_string_provider.count
			create area.make_filled ('%U', l_count + 1)
			count := l_count
			internal_hash_code := 0
			internal_case_insensitive_hash_code := 0;
			C_string_provider.read_substring_into_character_8_area (area, 1, l_count)
		end

	make_from_c_byte_array (a_byte_array: POINTER; a_character_count: INTEGER_32)
			-- Initialize from contents of a_byte_array for a length of a_character_count,
			-- given that each character is encoded in 1 single byte.
			-- ex: (char*) "abc"  for STRING_8 "abc"			
		require
			a_byte_array_exists: not a_byte_array.is_default_pointer
		do
			C_string_provider.set_shared_from_pointer_and_count (a_byte_array, a_character_count)
			create area.make_filled ('%U', a_character_count + 1)
			count := a_character_count
			internal_hash_code := 0;
			C_string_provider.read_substring_into_character_8_area (area, 1, a_character_count)
		end

	make_from_c_pointer (c_string: POINTER)
		obsolete "Use `make_from_c' instead. [2017-05-31]"
			-- Create new instance from contents of c_string,
			-- a string created by some C function.
		require
			c_string_exists: c_string /= default_pointer
		do
			make_from_c (c_string)
		end

	make_from_c_substring (c_string: POINTER; start_pos, end_pos: INTEGER_32)
			-- Initialize from substring of c_string,
			-- between start_pos and end_pos,
			-- c_string created by some C function.
		require
			c_string_exists: c_string /= default_pointer
			start_position_big_enough: start_pos >= 1
			end_position_big_enough: start_pos <= end_pos + 1
		local
			l_count: INTEGER_32
		do
			l_count := end_pos - start_pos + 1;
			C_string_provider.set_shared_from_pointer_and_count (c_string + (start_pos - 1), l_count)
			create area.make_filled ('%U', l_count + 1)
			count := l_count
			internal_hash_code := 0
			internal_case_insensitive_hash_code := 0;
			C_string_provider.read_substring_into_character_8_area (area, 1, l_count)
		end

	make_from_cil (a_system_string: detachable SYSTEM_STRING)
			-- Initialize Current with a_system_string.
		require
			is_dotnet: {PLATFORM}.is_dotnet
		deferred
		end

	make_from_separate (other: separate READABLE_STRING_8)
			-- Initialize current string from other.
		require
			other_not_void: other /= Void
		local
			i, nb: INTEGER_32
			l_area: like area
		do
			nb := other.count
			make (nb)
			from
				l_area := area
				i := 0
			until
				i = nb
			loop
				l_area.put (other.area.item (i), i)
				i := i + 1
			end
			count := nb
		ensure
			same_string: 
		end

	make_from_string (s: READABLE_STRING_8)
			-- Initialize from the characters of s.
		require
			string_exists: s /= Void
		do
			area := s.area
			count := s.count
			internal_hash_code := 0
			internal_case_insensitive_hash_code := 0
			if Current /= s then
				create area.make_empty (count + 1);
				area.copy_data (s.area, s.area_lower, 0, count + 1)
			end
		ensure
			not_shared_implementation: Current /= s implies not shared_with (s)
			initialized: same_string (s)
		end
	
feature -- Access

	at alias "@" (i: INTEGER_32): CHARACTER_8
			-- Character at position i.
			-- Was declared in READABLE_STRING_8 as synonym of item.
		deferred
		end

	case_insensitive_hash_code: INTEGER_32
			-- Hash code value of the lower case version of Current.
			-- (from READABLE_STRING_GENERAL)
		local
			l_props: like Character_properties
			i, nb: INTEGER_32
		do
			Result := internal_case_insensitive_hash_code
			if Result = 0 then
				from
					i := 1
					nb := count
					l_props := Character_properties
				until
					i > nb
				loop
					Result := ((Result \\ 8388593) |<< 8) + l_props.to_lower (character_32_item (i)).code
					i := i + 1
				end
				internal_case_insensitive_hash_code := Result
			end
		ensure -- from READABLE_STRING_GENERAL
			consistent: Result = as_lower.case_insensitive_hash_code
		end

	code (i: INTEGER_32): NATURAL_32
			-- Code at position i
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			valid_index: valid_index (i)
		deferred
		end

	False_constant: STRING_8 = "false"
			-- Constant string "false"
			-- (from READABLE_STRING_GENERAL)

	fuzzy_index (other: READABLE_STRING_GENERAL; start: INTEGER_32; fuzz: INTEGER_32): INTEGER_32
			-- Position of first occurrence of other at or after start
			-- with 0..fuzz mismatches between the string and other.
			-- 0 if there are no fuzzy matches
		require -- from READABLE_STRING_GENERAL
			other_exists: other /= Void
			other_not_empty: not other.is_empty
			start_large_enough: start >= 1
			start_small_enough: start <= count
			acceptable_fuzzy: fuzz <= other.count
		do
			Result := String_searcher.fuzzy_index (Current, other, start, count, fuzz)
		end

	generating_type: TYPE [detachable READABLE_STRING_8]
			-- Type of current object
			-- (type of which it is a direct instance)
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			generating_type_not_void: Result /= Void
		end

	generator: STRING_8
			-- Name of current object's generating class
			-- (base class of the type of which it is a direct instance)
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			generator_not_void: Result /= Void
			generator_not_empty: not Result.is_empty
		end

	hash_code: INTEGER_32
			-- Hash code value
			-- (from READABLE_STRING_GENERAL)
		local
			i, nb: INTEGER_32
		do
			Result := internal_hash_code
			if Result = 0 then
				from
					i := 1
					nb := count
				until
					i > nb
				loop
					Result := ((Result \\ 8388593) |<< 8) + character_32_item (i).code
					i := i + 1
				end
				internal_hash_code := Result
			end
		ensure -- from HASHABLE
			good_hash_value: Result >= 0
		end

	index_of (c: CHARACTER_8; start_index: INTEGER_32): INTEGER_32
			-- Position of first occurrence of c at or after start_index;
			-- 0 if none.
		require
			start_large_enough: start_index >= 1
			start_small_enough: start_index <= count + 1
		local
			a: like area
			i, nb, l_lower_area: INTEGER_32
		do
			nb := count
			if start_index <= nb then
				from
					l_lower_area := area_lower
					i := start_index - 1 + l_lower_area
					nb := nb + l_lower_area
					a := area
				until
					i = nb or else a.item (i) = c
				loop
					i := i + 1
				end
				if i < nb then
					Result := i + 1 - l_lower_area
				end
			end
		ensure
			valid_result: Result = 0 or (start_index <= Result and Result <= count)
			zero_if_absent: (Result = 0) = not substring (start_index, count).has (c)
			found_if_present: substring (start_index, count).has (c) implies item (Result) = c
			none_before: substring (start_index, count).has (c) implies not substring (start_index, Result - 1).has (c)
		end

	character_32_index_of (c: like character_32_item; start_index: INTEGER_32): INTEGER_32
			-- Position of first occurrence of c at or after start_index;
			-- 0 if none.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			start_large_enough: start_index >= 1
			start_small_enough: start_index <= count + 1
		local
			i, nb: INTEGER_32
		do
			nb := count
			if start_index <= nb then
				from
					i := start_index
				until
					i > nb or else character_32_item (i) = c
				loop
					i := i + 1
				end
				if i <= nb then
					Result := i
				end
			end
		ensure -- from READABLE_STRING_GENERAL
			valid_result: Result = 0 or (start_index <= Result and Result <= count)
			zero_if_absent: (Result = 0) = not substring (start_index, count).character_32_has (c)
			found_if_present: substring (start_index, count).character_32_has (c) implies character_32_item (Result) = c
			none_before: substring (start_index, count).character_32_has (c) implies not substring (start_index, Result - 1).character_32_has (c)
		end

	index_of_code (c: like code; start_index: INTEGER_32): INTEGER_32
			-- Position of first occurrence of c at or after start_index;
			-- 0 if none.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			start_large_enough: start_index >= 1
			start_small_enough: start_index <= count + 1
		local
			i, nb: INTEGER_32
		do
			nb := count
			if start_index <= nb then
				from
					i := start_index
				until
					i > nb or else code (i) = c
				loop
					i := i + 1
				end
				if i <= nb then
					Result := i
				end
			end
		ensure -- from READABLE_STRING_GENERAL
			valid_result: Result = 0 or (start_index <= Result and Result <= count)
			zero_if_absent: (Result = 0) = not substring (start_index, count).has_code (c)
			found_if_present: substring (start_index, count).has_code (c) implies code (Result) = c
			none_before: substring (start_index, count).has_code (c) implies not substring (start_index, Result - 1).has_code (c)
		end

	item alias "[]" (i: INTEGER_32): CHARACTER_8
			-- Character at position i.
			-- Was declared in READABLE_STRING_8 as synonym of at.
		require -- from READABLE_INDEXABLE
			valid_index: valid_index (i)
		deferred
		end

	character_32_item (i: INTEGER_32): CHARACTER_32
			-- Character at position i.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			valid_index: valid_index (i)
		deferred
		end

	item_code (i: INTEGER_32): INTEGER_32
		obsolete "For consistency with Unicode string handling, use `code (i)' instead. [2017-05-31]"
			-- Numeric code of character at position i.
		require
			index_small_enough: i <= count
			index_large_enough: i > 0
		deferred
		end

	last_index_of (c: CHARACTER_8; start_index_from_end: INTEGER_32): INTEGER_32
			-- Position of last occurrence of c,
			-- 0 if none.
		require
			start_index_small_enough: start_index_from_end <= count
			start_index_large_enough: start_index_from_end >= 1
		local
			a: like area
			i, l_lower_area: INTEGER_32
		do
			from
				l_lower_area := area_lower
				i := start_index_from_end - 1 + l_lower_area
				a := area
			until
				i < l_lower_area or else a.item (i) = c
			loop
				i := i - 1
			end
			Result := i + 1 - l_lower_area
		ensure
			valid_result: 0 <= Result and Result <= start_index_from_end
			zero_if_absent: (Result = 0) = not substring (1, start_index_from_end).has (c)
			found_if_present: substring (1, start_index_from_end).has (c) implies item (Result) = c
			none_after: substring (1, start_index_from_end).has (c) implies not substring (Result + 1, start_index_from_end).has (c)
		end

	character_32_last_index_of (c: like character_32_item; start_index_from_end: INTEGER_32): INTEGER_32
			-- Position of last occurrence of c.
			-- 0 if none.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			start_index_small_enough: start_index_from_end <= count
			start_index_large_enough: start_index_from_end >= 1
		do
			from
				Result := start_index_from_end
			until
				Result <= 0 or else character_32_item (Result) = c
			loop
				Result := Result - 1
			end
		ensure -- from READABLE_STRING_GENERAL
			valid_result: 0 <= Result and Result <= start_index_from_end
			zero_if_absent: (Result = 0) = not substring (1, start_index_from_end).character_32_has (c)
			found_if_present: substring (1, start_index_from_end).character_32_has (c) implies character_32_item (Result) = c
			none_after: substring (1, start_index_from_end).character_32_has (c) implies not substring (Result + 1, start_index_from_end).character_32_has (c)
		end

	last_index_of_code (c: like code; start_index_from_end: INTEGER_32): INTEGER_32
			-- Position of last occurrence of c.
			-- 0 if none.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			start_index_small_enough: start_index_from_end <= count
			start_index_large_enough: start_index_from_end >= 1
		do
			from
				Result := start_index_from_end
			until
				Result <= 0 or else code (Result) = c
			loop
				Result := Result - 1
			end
		ensure -- from READABLE_STRING_GENERAL
			valid_result: 0 <= Result and Result <= start_index_from_end
			zero_if_absent: (Result = 0) = not substring (1, start_index_from_end).has_code (c)
			found_if_present: substring (1, start_index_from_end).has_code (c) implies code (Result) = c
			none_after: substring (1, start_index_from_end).has_code (c) implies not substring (Result + 1, start_index_from_end).has_code (c)
		end

	new_cursor: STRING_8_ITERATION_CURSOR
			-- Fresh cursor associated with current structure
		require -- from  ITERABLE
			True
		do
			create Result.make (Current)
		ensure -- from ITERABLE
			result_attached: Result /= Void
		end

	shared_with (other: READABLE_STRING_8): BOOLEAN
			-- Does string share the text of other?
		do
			Result := (other /= Void) and then (area = other.area)
		end

	string: STRING_8
			-- New STRING_8 having same character sequence as Current.
		do
			create Result.make_from_string (Current)
		ensure
			string_not_void: Result /= Void
			string_type: Result.same_type (create {STRING_8}.make_empty)
			first_item: count > 0 implies Result.item (1) = item (1)
			recurse: count > 1 implies Result.substring (2, count) ~ substring (2, count).string
		end

	string_representation: STRING_8
			-- Similar to string but only create a new object if Current is not of dynamic type STRING_8.
		do
			if same_type (create {STRING_8}.make_empty) and then attached {STRING_8} Current as l_s8 then
				Result := l_s8
			else
				Result := string
			end
		ensure
			result_not_void: Result /= Void
			correct_type: Result.same_type (create {STRING_8}.make_empty)
			first_item: count > 0 implies Result.item (1) = item (1)
			recurse: count > 1 implies Result.substring (2, count) ~ substring (2, count).string
		end

	substring_index (other: READABLE_STRING_GENERAL; start_index: INTEGER_32): INTEGER_32
			-- Index of first occurrence of other at or after start_index;
			-- 0 if none
		require -- from READABLE_STRING_GENERAL
			other_not_void: other /= Void
			valid_start_index: start_index >= 1 and start_index <= count + 1
		do
			Result := String_searcher.substring_index (Current, other, start_index, count)
		ensure -- from READABLE_STRING_GENERAL
			valid_result: Result = 0 or else (start_index <= Result and Result <= count - other.count + 1)
			zero_if_absent: (Result = 0) = not substring (start_index, count).has_substring (other)
			at_this_index: Result >= start_index implies other.same_string (substring (Result, Result + other.count - 1))
			none_before: Result > start_index implies not substring (start_index, Result + other.count - 2).has_substring (other)
		end

	substring_index_in_bounds (other: READABLE_STRING_GENERAL; start_pos, end_pos: INTEGER_32): INTEGER_32
			-- Position of first occurrence of other at or after start_pos
			-- and to or before end_pos;
			-- 0 if none.
		require -- from READABLE_STRING_GENERAL
			other_nonvoid: other /= Void
			other_notempty: not other.is_empty
			start_pos_large_enough: start_pos >= 1
			start_pos_small_enough: start_pos <= count
			end_pos_large_enough: end_pos >= start_pos
			end_pos_small_enough: end_pos <= count
		do
			Result := String_searcher.substring_index (Current, other, start_pos, end_pos)
		ensure -- from READABLE_STRING_GENERAL
			correct_place: Result > 0 implies other.same_string (substring (Result, Result + other.count - 1))
		end

	True_constant: STRING_8 = "true"
			-- Constant string "true"
			-- (from READABLE_STRING_GENERAL)
	
feature -- Measurement

	capacity: INTEGER_32
			-- Number of characters allocated in Current
		do
			Result := area.count - 1
		ensure -- from READABLE_STRING_GENERAL
			capacity_non_negative: Result >= 0
		end

	count: INTEGER_32
			-- Actual number of characters making up the string.

	index_set: INTEGER_INTERVAL
		obsolete "Use `lower' and `upper' instead. [2017-05-31]"
			-- Range of acceptable indexes.
			-- (from READABLE_INDEXABLE)
		do
			create Result.make (Lower, count)
		ensure -- from READABLE_INDEXABLE
			not_void: Result /= Void
			empty_if_not_in_order: (Lower > count) implies Result.is_empty
			same_lower_if_not_empty: (Lower <= count) implies Result.lower = Lower
			same_upper_if_not_empty: (Lower <= count) implies Result.upper = count
		end

	Lower: INTEGER_32 = 1
			-- Minimum index.

	occurrences (c: CHARACTER_8): INTEGER_32
			-- Number of times c appears in the string.
		local
			i, nb: INTEGER_32
			a: SPECIAL [CHARACTER_8]
		do
			from
				i := area_lower
				nb := count + i
				a := area
			until
				i = nb
			loop
				if a.item (i) = c then
					Result := Result + 1
				end
				i := i + 1
			end
		ensure then
			zero_if_empty: count = 0 implies Result = 0
			recurse_if_not_found_at_first_position: (count > 0 and then item (1) /= c) implies Result = substring (2, count).occurrences (c)
			recurse_if_found_at_first_position: (count > 0 and then item (1) = c) implies Result = 1 + substring (2, count).occurrences (c)
		end

	character_32_occurrences (c: CHARACTER_32): INTEGER_32
			-- Number of times c appears in the string
			-- (from READABLE_STRING_GENERAL)
		local
			i, nb: INTEGER_32
		do
			nb := count
			if nb > 0 then
				from
					i := 1
				until
					i > nb
				loop
					if character_32_item (i) = c then
						Result := Result + 1
					end
					i := i + 1
				end
			end
		ensure then -- from READABLE_STRING_GENERAL
			zero_if_empty: count = 0 implies Result = 0
			recurse_if_not_found_at_first_position: (count > 0 and then character_32_item (1) /= c) implies Result = substring (2, count).character_32_occurrences (c)
			recurse_if_found_at_first_position: (count > 0 and then character_32_item (1) = c) implies Result = 1 + substring (2, count).character_32_occurrences (c)
		end
	
feature -- Comparison

	frozen deep_equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void
			-- or attached to isomorphic object structures?
			-- (from ANY)
		do
			if a = Void then
				Result := b = Void
			else
				Result := b /= Void and then a.is_deep_equal (b)
			end
		ensure -- from ANY
			instance_free: class
			shallow_implies_deep: standard_equal (a, b) implies Result
			both_or_none_void: (a = Void) implies (Result = (b = Void))
			same_type: (Result and (a /= Void)) implies (b /= Void and then a.same_type (b))
			symmetric: Result implies deep_equal (b, a)
		end

	ends_with_general (s: READABLE_STRING_GENERAL): BOOLEAN
			-- Does string finish with s?
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			argument_not_void: s /= Void
		local
			i, j: INTEGER_32
		do
			if Current = s then
				Result := True
			else
				i := s.count
				j := count
				if i <= j then
					from
						Result := True
					until
						i = 0
					loop
						if code (j) /= s.code (i) then
							Result := False
							i := 1
						end
						i := i - 1
						j := j - 1
					end
				end
			end
		ensure -- from READABLE_STRING_GENERAL
			definition: Result = s.same_string (substring (count - s.count + 1, count))
		end

	frozen equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void or attached
			-- to objects considered equal?
			-- (from ANY)
		do
			if a = Void then
				Result := b = Void
			else
				Result := b /= Void and then a.is_equal (b)
			end
		ensure -- from ANY
			instance_free: class
			definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.is_equal (b))
		end

	has_substring (other: READABLE_STRING_GENERAL): BOOLEAN
			-- Does Current contain other?
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			other_not_void: other /= Void
		do
			if other = Current then
				Result := True
			elseif other.count <= count then
				Result := substring_index (other, 1) > 0
			end
		ensure -- from READABLE_STRING_GENERAL
			false_if_too_small: count < other.count implies not Result
			true_if_initial: (count >= other.count and then other.same_string (substring (1, other.count))) implies Result
			recurse: (count >= other.count and then not other.same_string (substring (1, other.count))) implies (Result = substring (2, count).has_substring (other))
		end

	is_case_insensitive_equal_general (other: READABLE_STRING_GENERAL): BOOLEAN
			-- Is string made of same character sequence as other regardless of casing
			-- (possibly with a different capacity)?
			-- (from READABLE_STRING_GENERAL)
		local
			nb: INTEGER_32
		do
			if other = Current then
				Result := True
			else
				nb := count
				if nb = other.count then
					Result := nb = 0 or else same_caseless_characters_general (other, 1, nb, 1)
				end
			end
		ensure -- from READABLE_STRING_GENERAL
			symmetric: Result implies other.is_case_insensitive_equal (Current)
			consistent: attached {READABLE_STRING_8} other as l_other implies (standard_is_equal (l_other) implies Result)
			valid_result: as_lower ~ other.as_lower implies Result
		end

	is_case_insensitive_equal (other: READABLE_STRING_8): BOOLEAN
			-- Is string made of same character sequence as other regardless of casing
			-- (possibly with a different capacity)?
		require
			other_not_void: other /= Void
		local
			nb: INTEGER_32
		do
			if other = Current then
				Result := True
			else
				nb := count
				if nb = other.count then
					Result := nb = 0 or else same_caseless_characters (other, 1, nb, 1)
				end
			end
		ensure
			symmetric: Result implies other.is_case_insensitive_equal (Current)
			consistent: attached {like Current} other as l_other implies (standard_is_equal (l_other) implies Result)
			valid_result: as_lower.same_string (other.as_lower) implies Result
		end

	frozen is_deep_equal alias "≡≡≡" (other: READABLE_STRING_8): BOOLEAN
			-- Are Current and other attached to isomorphic object structures?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		ensure -- from ANY
			shallow_implies_deep: standard_is_equal (other) implies Result
			same_type: Result implies same_type (other)
			symmetric: Result implies other.is_deep_equal (Current)
		end

	is_equal (other: like Current): BOOLEAN
			-- Is string made of same character sequence as other
			-- (possibly with a different capacity)?
		require -- from ANY
			other_not_void: other /= Void
		local
			nb: INTEGER_32
			l_hash, l_other_hash: like internal_hash_code
		do
			if other = Current then
				Result := True
			else
				nb := count
				if nb = other.count then
					l_hash := internal_hash_code
					l_other_hash := other.internal_hash_code
					if l_hash = 0 or else l_other_hash = 0 or else l_hash = l_other_hash then
						Result := area.same_items (other.area, other.area_lower, area_lower, nb)
					end
				end
			end
		ensure -- from ANY
			symmetric: Result implies other ~ Current
			consistent: standard_is_equal (other) implies Result
		ensure then -- from COMPARABLE
			trichotomy: Result = (not (Current < other) and not (other < Current))
		end

	is_greater alias ">" (other: READABLE_STRING_8): BOOLEAN
			-- Is current object greater than other?
			-- (from COMPARABLE)
		require -- from PART_COMPARABLE
			other_exists: other /= Void
		do
			Result := other < Current
		ensure then -- from COMPARABLE
			definition: Result = (other < Current)
		end

	is_greater_equal alias ">=" alias "≥" (other: READABLE_STRING_8): BOOLEAN
			-- Is current object greater than or equal to other?
			-- (from COMPARABLE)
		require -- from PART_COMPARABLE
			other_exists: other /= Void
		do
			Result := not (Current < other)
		ensure then -- from COMPARABLE
			definition: Result = (other <= Current)
		end

	is_less alias "<" (other: like Current): BOOLEAN
			-- Is string lexicographically lower than other?
		require -- from PART_COMPARABLE
			other_exists: other /= Void
		local
			other_count: INTEGER_32
			current_count: INTEGER_32
		do
			if other /= Current then
				other_count := other.count
				current_count := count
				if other_count = current_count then
					Result := str_strict_cmp (other.area, area, other.area_lower, area_lower, other_count) > 0
				else
					if current_count < other_count then
						Result := str_strict_cmp (other.area, area, other.area_lower, area_lower, current_count) >= 0
					else
						Result := str_strict_cmp (other.area, area, other.area_lower, area_lower, other_count) > 0
					end
				end
			end
		ensure then -- from COMPARABLE
			asymmetric: Result implies not (other < Current)
		end

	is_less_equal alias "<=" alias "≤" (other: READABLE_STRING_8): BOOLEAN
			-- Is current object less than or equal to other?
			-- (from COMPARABLE)
		require -- from PART_COMPARABLE
			other_exists: other /= Void
		do
			Result := not (other < Current)
		ensure then -- from COMPARABLE
			definition: Result = ((Current < other) or (Current ~ other))
		end

	max alias "∨" (other: READABLE_STRING_8): READABLE_STRING_8
			-- The greater of current object and other
			-- (from COMPARABLE)
		require -- from COMPARABLE
			other_exists: other /= Void
		do
			if Current >= other then
				Result := Current
			else
				Result := other
			end
		ensure -- from COMPARABLE
			current_if_not_smaller: Current >= other implies Result = Current
			other_if_smaller: Current < other implies Result = other
		end

	min alias "∧" (other: READABLE_STRING_8): READABLE_STRING_8
			-- The smaller of current object and other
			-- (from COMPARABLE)
		require -- from COMPARABLE
			other_exists: other /= Void
		do
			if Current <= other then
				Result := Current
			else
				Result := other
			end
		ensure -- from COMPARABLE
			current_if_not_greater: Current <= other implies Result = Current
			other_if_greater: Current > other implies Result = other
		end

	same_caseless_characters_general (other: READABLE_STRING_GENERAL; start_pos, end_pos, index_pos: INTEGER_32): BOOLEAN
			-- Are characters of other within bounds start_pos and end_pos
			-- caseless identical to characters of current string starting at index index_pos.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			other_not_void: other /= Void
			valid_start_pos: other.valid_index (start_pos)
			valid_end_pos: other.valid_index (end_pos)
			valid_bounds: (start_pos <= end_pos) or (start_pos = end_pos + 1)
			valid_index_pos: valid_index (index_pos)
		local
			i, j, nb: INTEGER_32
			l_prop: like Character_properties
			c1, c2: like character_32_item
		do
			nb := end_pos - start_pos + 1
			if nb <= count - index_pos + 1 then
				from
					l_prop := Character_properties
					Result := True
					i := index_pos
					j := start_pos
					nb := nb + i
				variant
					increasing_index: nb - i + 1
				until
					i = nb
				loop
					c1 := character_32_item (i)
					c2 := other.item (j)
					if c1 /= c2 and then l_prop.to_lower (c1) /= l_prop.to_lower (c2) then
						Result := False
						i := nb - 1
					end
					i := i + 1
					j := j + 1
				end
			end
		ensure -- from READABLE_STRING_GENERAL
			same_characters: Result = substring (index_pos, index_pos + end_pos - start_pos).is_case_insensitive_equal_general (other.substring (start_pos, end_pos))
		end

	same_caseless_characters (other: READABLE_STRING_8; start_pos, end_pos, index_pos: INTEGER_32): BOOLEAN
			-- Are characters of other within bounds start_pos and end_pos
			-- caseless identical to characters of current string starting at index index_pos.
		require
			other_not_void: other /= Void
			valid_start_pos: other.valid_index (start_pos)
			valid_end_pos: other.valid_index (end_pos)
			valid_bounds: (start_pos <= end_pos) or (start_pos = end_pos + 1)
			valid_index_pos: valid_index (index_pos)
		local
			i, j, nb: INTEGER_32
			l_area, l_other_area: like area
			c1, c2: CHARACTER_8
		do
			nb := end_pos - start_pos + 1
			if nb <= count - index_pos + 1 then
				from
					l_area := area
					l_other_area := other.area
					Result := True
					i := area_lower + index_pos - 1
					j := other.area_lower + start_pos - 1
					nb := nb + i
				variant
					increasing_index: l_area.upper - i + 1
				until
					i = nb
				loop
					c1 := l_area.item (i)
					c2 := l_other_area.item (j)
					if c1 /= c2 and then c1.as_lower /= c2.as_lower then
						Result := False
						i := nb - 1
					end
					i := i + 1
					j := j + 1
				end
			end
		ensure
			same_characters: Result = substring (index_pos, index_pos + end_pos - start_pos).is_case_insensitive_equal (other.substring (start_pos, end_pos))
		end

	same_characters_general (other: READABLE_STRING_GENERAL; start_pos, end_pos, index_pos: INTEGER_32): BOOLEAN
			-- Are characters of other within bounds start_pos and end_pos
			-- identical to characters of current string starting at index index_pos.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			other_not_void: other /= Void
			valid_start_pos: other.valid_index (start_pos)
			valid_end_pos: other.valid_index (end_pos)
			valid_bounds: (start_pos <= end_pos) or (start_pos = end_pos + 1)
			valid_index_pos: valid_index (index_pos)
		local
			i, j, nb: INTEGER_32
		do
			nb := end_pos - start_pos + 1
			if nb <= count - index_pos + 1 then
				from
					Result := True
					i := index_pos
					j := start_pos
					nb := nb + i
				variant
					increasing_index: nb - i + 1
				until
					i = nb
				loop
					if character_32_item (i) /= other.item (j) then
						Result := False
						i := nb - 1
					end
					i := i + 1
					j := j + 1
				end
			end
		ensure -- from READABLE_STRING_GENERAL
			same_characters: Result = substring (index_pos, index_pos + end_pos - start_pos).same_string_general (other.substring (start_pos, end_pos))
		end

	same_characters (other: READABLE_STRING_8; start_pos, end_pos, index_pos: INTEGER_32): BOOLEAN
			-- Are characters of other within bounds start_pos and end_pos
			-- identical to characters of current string starting at index index_pos.
		require
			other_not_void: other /= Void
			valid_start_pos: other.valid_index (start_pos)
			valid_end_pos: other.valid_index (end_pos)
			valid_bounds: (start_pos <= end_pos) or (start_pos = end_pos + 1)
			valid_index_pos: valid_index (index_pos)
		local
			nb: INTEGER_32
		do
			nb := end_pos - start_pos + 1
			if nb <= count - index_pos + 1 then
				Result := area.same_items (other.area, other.area_lower + start_pos - 1, area_lower + index_pos - 1, nb)
			end
		ensure
			same_characters: Result = substring (index_pos, index_pos + end_pos - start_pos).same_string (other.substring (start_pos, end_pos))
		end

	same_string (other: READABLE_STRING_8): BOOLEAN
			-- Do Current and other have same character sequence?
		require
			other_not_void: other /= Void
		local
			nb: INTEGER_32
		do
			if other = Current then
				Result := True
			else
				nb := count
				if nb = other.count then
					Result := nb = 0 or else same_characters (other, 1, nb, 1)
				end
			end
		ensure
			definition: Result = (string ~ other.string)
		end

	same_string_general (other: READABLE_STRING_GENERAL): BOOLEAN
			-- Does other represent the same string as Current?
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			other_not_void: other /= Void
		local
			nb: INTEGER_32
		do
			if other = Current then
				Result := True
			else
				nb := count
				if nb = other.count then
					Result := nb = 0 or else same_characters_general (other, 1, nb, 1)
				end
			end
		end

	frozen standard_equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void or attached to
			-- field-by-field identical objects of the same type?
			-- Always uses default object comparison criterion.
			-- (from ANY)
		do
			if a = Void then
				Result := b = Void
			else
				Result := b /= Void and then a.standard_is_equal (b)
			end
		ensure -- from ANY
			instance_free: class
			definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.standard_is_equal (b))
		end

	frozen standard_is_equal alias "≜" (other: READABLE_STRING_8): BOOLEAN
			-- Is other attached to an object of the same type
			-- as current object, and field-by-field identical to it?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		ensure -- from ANY
			same_type: Result implies same_type (other)
			symmetric: Result implies other.standard_is_equal (Current)
		end

	starts_with_general (s: READABLE_STRING_GENERAL): BOOLEAN
			-- Does string begin with s?
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			argument_not_void: s /= Void
		local
			i: INTEGER_32
		do
			if Current = s then
				Result := True
			else
				i := s.count
				if i <= count then
					from
						Result := True
					until
						i = 0
					loop
						if code (i) /= s.code (i) then
							Result := False
							i := 1
						end
						i := i - 1
					end
				end
			end
		ensure -- from READABLE_STRING_GENERAL
			definition: Result = s.same_string (substring (1, s.count))
		end

	three_way_comparison alias "â‹š" (other: READABLE_STRING_8): INTEGER_32
			-- If current object equal to other, 0;
			-- if smaller, -1; if greater, 1
			-- (from COMPARABLE)
		require -- from COMPARABLE
			other_exists: other /= Void
		do
			if Current < other then
				Result := -1
			elseif other < Current then
				Result := 1
			end
		ensure -- from COMPARABLE
			equal_zero: (Result = 0) = (Current ~ other)
			smaller_negative: (Result = -1) = (Current < other)
			greater_positive: (Result = 1) = (Current > other)
		end
	
feature -- Status report

	conforms_to (other: ANY): BOOLEAN
			-- Does type of current object conform to type
			-- of other (as per Eiffel: The Language, chapter 13)?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		end

	ends_with (s: READABLE_STRING_8): BOOLEAN
			-- Does string finish with s?
		require
			argument_not_void: s /= Void
		local
			i, j, nb: INTEGER_32
			l_area, l_s_area: like area
		do
			if Current = s then
				Result := True
			else
				i := s.count
				j := count
				if i <= j then
					from
						l_area := area
						l_s_area := s.area
						j := area_upper + 1
						i := s.area_upper + 1
						nb := s.area_lower
						Result := True
					until
						i = nb
					loop
						i := i - 1
						j := j - 1
						if l_area.item (j) /= l_s_area.item (i) then
							Result := False
							i := nb
						end
					end
				end
			end
		ensure
			definition: Result = s.same_string (substring (count - s.count + 1, count))
		end

	has (c: CHARACTER_8): BOOLEAN
			-- Does string include c?
		local
			i, nb: INTEGER_32
			l_area: like area
		do
			nb := count
			if nb > 0 then
				from
					i := area_lower
					l_area := area
					nb := nb + i
				until
					i = nb or else (l_area.item (i) = c)
				loop
					i := i + 1
				end
				Result := i < nb
			end
		ensure
			false_if_empty: count = 0 implies not Result
			true_if_first: count > 0 and then item (1) = c implies Result
			recurse: (count > 0 and then item (1) /= c) implies (Result = substring (2, count).has (c))
		end

	character_32_has (c: like character_32_item): BOOLEAN
			-- Does string include c?
			-- (from READABLE_STRING_GENERAL)
		local
			i, nb: INTEGER_32
		do
			nb := count
			if nb > 0 then
				from
					i := 1
				until
					i > nb or else (character_32_item (i) = c)
				loop
					i := i + 1
				end
				Result := i <= nb
			end
		ensure then -- from READABLE_STRING_GENERAL
			false_if_empty: count = 0 implies not Result
			true_if_first: count > 0 and then character_32_item (1) = c implies Result
			recurse: (count > 0 and then character_32_item (1) /= c) implies (Result = substring (2, count).character_32_has (c))
		end

	has_code (c: like code): BOOLEAN
			-- Does string include c?
			-- (from READABLE_STRING_GENERAL)
		local
			i, nb: INTEGER_32
		do
			nb := count
			if nb > 0 then
				from
					i := 1
				until
					i > nb or else (code (i) = c)
				loop
					i := i + 1
				end
				Result := i <= nb
			end
		ensure then -- from READABLE_STRING_GENERAL
			false_if_empty: count = 0 implies not Result
			true_if_first: count > 0 and then code (1) = c implies Result
			recurse: (count > 0 and then code (1) /= c) implies (Result = substring (2, count).has_code (c))
		end

	is_boolean: BOOLEAN
			-- Does Current represent a BOOLEAN?
		local
			nb: INTEGER_32
			l_area: like area
			i: INTEGER_32
		do
			nb := count
			if nb = 4 then
				l_area := area
				i := area_lower
				Result := l_area.item (i).lower = 't' and then l_area.item (i + 1).lower = 'r' and then l_area.item (i + 2).lower = 'u' and then l_area.item (i + 3).lower = 'e'
			elseif nb = 5 then
				l_area := area
				i := area_lower
				Result := l_area.item (i).lower = 'f' and then l_area.item (i + 1).lower = 'a' and then l_area.item (i + 2).lower = 'l' and then l_area.item (i + 3).lower = 's' and then l_area.item (i + 4).lower = 'e'
			end
		ensure -- from READABLE_STRING_GENERAL
			is_boolean: Result = (True_constant.same_string_general (as_lower) or False_constant.same_string_general (as_lower))
		end

	is_double: BOOLEAN
			-- Does Current represent a REAL_64?
			-- Was declared in READABLE_STRING_GENERAL as synonym of is_real_64.
			-- (from READABLE_STRING_GENERAL)
		local
			l_convertor: like Ctor_convertor
		do
			l_convertor := Ctor_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_double)
			Result := l_convertor.is_integral_double
		end

	is_empty: BOOLEAN
			-- Is structure empty?
			-- (from READABLE_STRING_GENERAL)
		deferred
		end

	is_hashable: BOOLEAN
			-- May current object be hashed?
			-- (True by default.)
			-- (from HASHABLE)
		do
			Result := True
		end

	is_immutable: BOOLEAN
			-- Can the character sequence of Current be not changed?
			-- (from READABLE_STRING_GENERAL)
		do
			Result := False
		end

	is_integer: BOOLEAN
			-- Does Current represent an INTEGER_32?
			-- Was declared in READABLE_STRING_GENERAL as synonym of is_integer_32.
			-- (from READABLE_STRING_GENERAL)
		do
			Result := is_valid_integer_or_natural ({NUMERIC_INFORMATION}.type_integer_32)
		end

	is_integer_16: BOOLEAN
			-- Does Current represent an INTEGER_16?
			-- (from READABLE_STRING_GENERAL)
		do
			Result := is_valid_integer_or_natural ({NUMERIC_INFORMATION}.type_integer_16)
		end

	is_integer_32: BOOLEAN
			-- Does Current represent an INTEGER_32?
			-- Was declared in READABLE_STRING_GENERAL as synonym of is_integer.
			-- (from READABLE_STRING_GENERAL)
		do
			Result := is_valid_integer_or_natural ({NUMERIC_INFORMATION}.type_integer_32)
		end

	is_integer_64: BOOLEAN
			-- Does Current represent an INTEGER_64?
			-- (from READABLE_STRING_GENERAL)
		do
			Result := is_valid_integer_or_natural ({NUMERIC_INFORMATION}.type_integer_64)
		end

	is_integer_8: BOOLEAN
			-- Does Current represent an INTEGER_8?
			-- (from READABLE_STRING_GENERAL)
		do
			Result := is_valid_integer_or_natural ({NUMERIC_INFORMATION}.type_integer_8)
		end

	is_natural: BOOLEAN
			-- Does Current represent a NATURAL_32?
			-- Was declared in READABLE_STRING_GENERAL as synonym of is_natural_32.
			-- (from READABLE_STRING_GENERAL)
		do
			Result := is_valid_integer_or_natural ({NUMERIC_INFORMATION}.type_natural_32)
		end

	is_natural_16: BOOLEAN
			-- Does Current represent a NATURAL_16?
			-- (from READABLE_STRING_GENERAL)
		do
			Result := is_valid_integer_or_natural ({NUMERIC_INFORMATION}.type_natural_16)
		end

	is_natural_32: BOOLEAN
			-- Does Current represent a NATURAL_32?
			-- Was declared in READABLE_STRING_GENERAL as synonym of is_natural.
			-- (from READABLE_STRING_GENERAL)
		do
			Result := is_valid_integer_or_natural ({NUMERIC_INFORMATION}.type_natural_32)
		end

	is_natural_64: BOOLEAN
			-- Does Current represent a NATURAL_64?
			-- (from READABLE_STRING_GENERAL)
		do
			Result := is_valid_integer_or_natural ({NUMERIC_INFORMATION}.type_natural_64)
		end

	is_natural_8: BOOLEAN
			-- Does Current represent a NATURAL_8?
			-- (from READABLE_STRING_GENERAL)
		do
			Result := is_valid_integer_or_natural ({NUMERIC_INFORMATION}.type_natural_8)
		end

	is_number_sequence: BOOLEAN
			-- Does Current represent a number sequence?
			-- (from READABLE_STRING_GENERAL)
		do
			Result := is_valid_integer_or_natural ({NUMERIC_INFORMATION}.type_no_limitation)
		end

	is_real: BOOLEAN
			-- Does Current represent a REAL_32?
			-- Was declared in READABLE_STRING_GENERAL as synonym of is_real_32.
			-- (from READABLE_STRING_GENERAL)
		local
			l_convertor: like Ctor_convertor
		do
			l_convertor := Ctor_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_real)
			Result := l_convertor.is_integral_real
		end

	is_real_32: BOOLEAN
			-- Does Current represent a REAL_32?
			-- Was declared in READABLE_STRING_GENERAL as synonym of is_real.
			-- (from READABLE_STRING_GENERAL)
		local
			l_convertor: like Ctor_convertor
		do
			l_convertor := Ctor_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_real)
			Result := l_convertor.is_integral_real
		end

	is_real_64: BOOLEAN
			-- Does Current represent a REAL_64?
			-- Was declared in READABLE_STRING_GENERAL as synonym of is_double.
			-- (from READABLE_STRING_GENERAL)
		local
			l_convertor: like Ctor_convertor
		do
			l_convertor := Ctor_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_double)
			Result := l_convertor.is_integral_double
		end

	is_real_sequence: BOOLEAN
			-- Does Current represent a real sequence?
			-- (from READABLE_STRING_GENERAL)
		local
			l_convertor: like Ctor_convertor
		do
			l_convertor := Ctor_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_no_limitation)
			Result := l_convertor.is_integral_double
		end

	Is_string_32: BOOLEAN = False
			-- Is Current a sequence of CHARACTER_32?

	Is_string_8: BOOLEAN = True
			-- Is Current a sequence of CHARACTER_8?

	is_substring_whitespace (start_index, end_index: INTEGER_32): BOOLEAN
			-- Is substring between start_index and end_index containing only whitespace characters?
		require -- from READABLE_STRING_GENERAL
			start_index_big_enough: 1 <= start_index
			end_index_small_enough: end_index <= count
			consistent_indexes: start_index - 1 <= end_index
		local
			i, n: INTEGER_32
			l_area: like area
		do
			from
				l_area := area
				i := area_lower + start_index - 1
				n := area_lower + end_index - 1
			until
				i > n or not l_area.item (i).is_space
			loop
				i := i + 1
			end
			Result := i > n
		end

	Is_valid_as_string_8: BOOLEAN = True
			-- Is Current convertible to a sequence of CHARACTER_8 without information loss?

	is_whitespace: BOOLEAN
			-- Is structure containing only whitespace characters?
			-- (from READABLE_STRING_GENERAL)
		do
			Result := is_substring_whitespace (1, count)
		end

	same_type (other: ANY): BOOLEAN
			-- Is type of current object identical to type of other?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		ensure -- from ANY
			definition: Result = (conforms_to (other) and other.conforms_to (Current))
		end

	starts_with (s: READABLE_STRING_8): BOOLEAN
			-- Does string begin with s?
		require
			argument_not_void: s /= Void
		local
			i, j, nb: INTEGER_32
			l_area, l_s_area: like area
		do
			if Current = s then
				Result := True
			else
				i := s.count
				if i <= count then
					from
						l_area := area
						l_s_area := s.area
						j := area_lower + i
						i := s.area_upper + 1
						nb := s.area_lower
						Result := True
					until
						i = nb
					loop
						i := i - 1
						j := j - 1
						if l_area.item (j) /= l_s_area.item (i) then
							Result := False
							i := nb
						end
					end
				end
			end
		ensure
			definition: Result = s.same_string (substring (1, s.count))
		end

	valid_code (v: NATURAL_32): BOOLEAN
			-- Is v a valid code for a CHARACTER_32?
		do
			Result := v <= {CHARACTER_8}.max_value.to_natural_32
		end

	valid_index (i: INTEGER_32): BOOLEAN
			-- Is i within the bounds of the string?
			-- (from READABLE_STRING_GENERAL)
		require -- from  READABLE_INDEXABLE
			True
		do
			Result := (i > 0) and (i <= count)
		ensure -- from READABLE_INDEXABLE
			only_if_in_index_set: Result implies (Lower <= i and i <= count)
		ensure -- from READABLE_STRING_GENERAL
			definition: Result = (1 <= i and i <= count)
		end
	
feature {NONE} -- Element change

	fill_character (c: CHARACTER_8)
			-- Fill with capacity characters all equal to c.
		local
			l_cap: like capacity
		do
			l_cap := capacity
			if l_cap /= 0 then
				area.fill_with (c, 0, l_cap - 1)
				count := l_cap
				internal_hash_code := 0
				internal_case_insensitive_hash_code := 0
			end
		ensure
			filled: count = capacity
			same_size: capacity = old capacity
		end
	
feature -- Element change

	plus_general (s: READABLE_STRING_GENERAL): READABLE_STRING_8
		obsolete "Use `plus` on sized variants of string classes. [2020-05-31]"
			-- Concatenation of the current string with s.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			argument_not_void: s /= Void
			compatible_strings: Is_string_8 implies s.is_valid_as_string_8
		deferred
		ensure -- from READABLE_STRING_GENERAL
			plus_not_void: Result /= Void
			new_count: Result.count = count + s.count
			initial: Elks_checking implies Result.substring (1, count) ~ Current
			final: Elks_checking implies Result.substring (count + 1, count + s.count).same_string_general (s)
		end
	
feature -- Conversion

	as_lower: READABLE_STRING_8
			-- New object with all letters in lower case.
			-- (from READABLE_STRING_GENERAL)
		deferred
		ensure -- from READABLE_STRING_GENERAL
			as_lower_attached: Result /= Void
			length: Result.count = count
			anchor: count > 0 implies Result.character_32_item (1) = character_32_item (1).as_lower
			recurse: count > 1 implies Result.substring (2, count) ~ substring (2, count).as_lower
		end

	as_readable_string_32: READABLE_STRING_32
		obsolete "Use explicit conversion `to_string_32`, or, better use READABLE_STRING_32 and descendants instead. [2017-05-31]"
			-- Equivalent to as_string_32 with a different name.
			-- (from READABLE_STRING_GENERAL)
		do
			Result := as_string_32
		end

	as_readable_string_8: READABLE_STRING_8
		obsolete "Use explicit conversion `to_string_8' with a test that the string is made of ASCII characters only. [2017-05-31]"
			-- Convert Current as a READABLE_STRING_8. If a code of Current is
			-- not a valid code for a READABLE_STRING_8 it is replaced with the null
			-- character.
			-- (from READABLE_STRING_GENERAL)
		do
			Result := as_string_8
		end

	as_string_32: STRING_32
			-- Convert Current as a STRING_32.
			-- Was declared in READABLE_STRING_GENERAL as synonym of to_string_32.
			-- (from READABLE_STRING_GENERAL)
		local
			i, nb: INTEGER_32
		do
			if attached {STRING_32} Current as l_result then
				Result := l_result
			else
				nb := count
				create Result.make (nb);
				Result.set_count (nb)
				from
					i := 1
				until
					i > nb
				loop
					Result.put_code (code (i), i)
					i := i + 1
				end
			end
		ensure -- from READABLE_STRING_GENERAL
			as_string_32_not_void: Result /= Void
			identity: (conforms_to (create {STRING_32}.make_empty) and Result = Current) or (not conforms_to (create {STRING_32}.make_empty) and Result /= Current)
		end

	as_string_32_conversion: STRING_32
		obsolete "Update target of call to use READABLE_STRING_32 and descendants instead. [2017-05-31]"
			-- Equivalent to as_string_32 with a different name.
			-- To be used for migrating existing code to Unicode
			-- when you get a compiler error but cannot or do not have
			-- the time yet to address the source of the string to be
			-- a READABLE_STRING_32 or descendants.
			-- (from READABLE_STRING_GENERAL)
		do
			Result := as_string_32
		end

	as_string_8: STRING_8
		obsolete "[
			For 32-bit strings:
				- use explicit conversion `to_string_8` with a test that the string is made of ASCII characters only.
			For 8-bit strings:
				- consider changing the type of reattachmanet target to READABLE_STRING_8 or
				- use explicit conversion `to_string_8` to avoid implicit performance penalty.
			[2019-11-30]
		]"
			-- Convert Current as a STRING_8. If a code of Current is
			-- not a valid code for a STRING_8 it is replaced with the null
			-- character.
			-- (from READABLE_STRING_GENERAL)
		local
			i, nb: INTEGER_32
			l_code: like code
		do
			if attached {STRING_8} Current as l_result then
				Result := l_result
			else
				nb := count
				create Result.make (nb);
				Result.set_count (nb)
				from
					i := 1
				until
					i > nb
				loop
					l_code := code (i)
					if Result.valid_code (l_code) then
						Result.put_code (l_code, i)
					else
						Result.put_code (0, i)
					end
					i := i + 1
				end
			end
		ensure -- from READABLE_STRING_GENERAL
			as_string_8_not_void: Result /= Void
			identity: (conforms_to ("") and Result = Current) or (not conforms_to ("") and Result /= Current)
		end

	as_string_8_conversion: STRING_8
		obsolete "Update recipient of call to use READABLE_STRING_32 and descendants instead. [2017-05-31]"
			-- Equivalent to as_string_8 with a different name.
			-- To be used for migrating existing code to Unicode
			-- when you get a compiler error but cannot or do not have
			-- the time yet to address the target recipient of the string to be
			-- a READABLE_STRING_32 or descendants.
			-- (from READABLE_STRING_GENERAL)
		do
			Result := as_string_8
		end

	as_upper: READABLE_STRING_8
			-- New object with all letters in upper case
			-- (from READABLE_STRING_GENERAL)
		deferred
		ensure -- from READABLE_STRING_GENERAL
			as_upper_attached: Result /= Void
			length: Result.count = count
			anchor: count > 0 implies Result.character_32_item (1) = character_32_item (1).as_upper
			recurse: count > 1 implies Result.substring (2, count) ~ substring (2, count).as_upper
		end

	mirrored: like Current
			-- Mirror image of string;
			-- Result for "Hello world" is "dlrow olleH".
		deferred
		ensure
			same_count: Result.count = count
		end

	split (a_separator: CHARACTER_32): LIST [READABLE_STRING_8]
			-- Split on a_separator.
			-- (from READABLE_STRING_GENERAL)
		local
			l_list: ARRAYED_LIST [READABLE_STRING_8]
			i, j, c: INTEGER_32
		do
			c := count
			create l_list.make (c + 1)
			if c > 0 then
				from
					i := 1
				until
					i > c
				loop
					j := character_32_index_of (a_separator, i)
					if j = 0 then
						j := c + 1
					end;
					l_list.extend (substring (i, j - 1))
					i := j + 1
				end
				if j = c then
					check
						last_character_is_a_separator: character_32_item (j) = a_separator
					end;
					l_list.extend (new_string (0))
				end
			else
				l_list.extend (new_string (0))
			end
			Result := l_list
			check
					l_list.count = character_32_occurrences (a_separator) + 1
			end
		ensure -- from READABLE_STRING_GENERAL
				Result /= Void
		end

	to_boolean: BOOLEAN
			-- Boolean value;
			-- "True" yields True, "False" yields False
			-- (case-insensitive)
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			is_boolean: is_boolean
		do
			check
					True_constant.count = 4
			end
			if count = 4 then
				Result := True
			end
		ensure -- from READABLE_STRING_GENERAL
			to_boolean: (Result = as_lower.same_string_general (True_constant)) or (not Result = as_lower.same_string_general (False_constant))
		end

	frozen to_cil: SYSTEM_STRING
			-- Create an instance of SYSTEM_STRING using characters
			-- of Current between indices 1 and count.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			is_dotnet: {PLATFORM}.is_dotnet
		do
			Result := Dotnet_convertor.from_string_to_system_string (Current)
		ensure -- from READABLE_STRING_GENERAL
			to_cil_not_void: Result /= Void
		end

	to_double: REAL_64
			-- "Double" value;
			-- for example, when applied to "123.0", will yield 123.0 (double)
			-- Was declared in READABLE_STRING_GENERAL as synonym of to_real_64.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			represents_a_double: is_double
		local
			l_convertor: like Ctor_convertor
		do
			l_convertor := Ctor_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_no_limitation)
			Result := l_convertor.parsed_double
		end

	to_integer: INTEGER_32
			-- 32-bit integer value
			-- Was declared in READABLE_STRING_GENERAL as synonym of to_integer_32.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			is_integer: is_integer_32
		local
			l_convertor: like Ctoi_convertor
		do
			l_convertor := Ctoi_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_no_limitation)
			Result := l_convertor.parsed_integer
		end

	to_integer_16: INTEGER_16
			-- 16-bit integer value
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			is_integer_16: is_integer_16
		local
			l_convertor: like Ctoi_convertor
		do
			l_convertor := Ctoi_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_no_limitation)
			Result := l_convertor.parsed_integer_16
		end

	to_integer_32: INTEGER_32
			-- 32-bit integer value
			-- Was declared in READABLE_STRING_GENERAL as synonym of to_integer.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			is_integer: is_integer_32
		local
			l_convertor: like Ctoi_convertor
		do
			l_convertor := Ctoi_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_no_limitation)
			Result := l_convertor.parsed_integer
		end

	to_integer_64: INTEGER_64
			-- 64-bit integer value
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			is_integer_64: is_integer_64
		local
			l_convertor: like Ctoi_convertor
		do
			l_convertor := Ctoi_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_no_limitation)
			Result := l_convertor.parsed_integer_64
		end

	to_integer_8: INTEGER_8
			-- 8-bit integer value
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			is_integer_8: is_integer_8
		local
			l_convertor: like Ctoi_convertor
		do
			l_convertor := Ctoi_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_no_limitation)
			Result := l_convertor.parsed_integer_8
		end

	to_natural: NATURAL_32
			-- 32-bit natural value
			-- Was declared in READABLE_STRING_GENERAL as synonym of to_natural_32.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			is_natural: is_natural_32
		local
			l_convertor: like Ctoi_convertor
		do
			l_convertor := Ctoi_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_no_limitation)
			Result := l_convertor.parsed_natural_32
		end

	to_natural_16: NATURAL_16
			-- 16-bit natural value
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			is_natural_16: is_natural_16
		local
			l_convertor: like Ctoi_convertor
		do
			l_convertor := Ctoi_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_no_limitation)
			Result := l_convertor.parsed_natural_16
		end

	to_natural_32: NATURAL_32
			-- 32-bit natural value
			-- Was declared in READABLE_STRING_GENERAL as synonym of to_natural.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			is_natural: is_natural_32
		local
			l_convertor: like Ctoi_convertor
		do
			l_convertor := Ctoi_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_no_limitation)
			Result := l_convertor.parsed_natural_32
		end

	to_natural_64: NATURAL_64
			-- 64-bit natural value
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			is_natural_64: is_natural_64
		local
			l_convertor: like Ctoi_convertor
		do
			l_convertor := Ctoi_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_no_limitation)
			Result := l_convertor.parsed_natural_64
		end

	to_natural_8: NATURAL_8
			-- 8-bit natural value
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			is_natural_8: is_natural_8
		local
			l_convertor: like Ctoi_convertor
		do
			l_convertor := Ctoi_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_no_limitation)
			Result := l_convertor.parsed_natural_8
		end

	to_real: REAL_32
			-- Real value;
			-- for example, when applied to "123.0", will yield 123.0
			-- Was declared in READABLE_STRING_GENERAL as synonym of to_real_32.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			represents_a_real: is_real
		do
			Result := to_double.truncated_to_real
		end

	to_real_32: REAL_32
			-- Real value;
			-- for example, when applied to "123.0", will yield 123.0
			-- Was declared in READABLE_STRING_GENERAL as synonym of to_real.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			represents_a_real: is_real
		do
			Result := to_double.truncated_to_real
		end

	to_real_64: REAL_64
			-- "Double" value;
			-- for example, when applied to "123.0", will yield 123.0 (double)
			-- Was declared in READABLE_STRING_GENERAL as synonym of to_double.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			represents_a_double: is_double
		local
			l_convertor: like Ctor_convertor
		do
			l_convertor := Ctor_convertor;
			l_convertor.parse_string_with_type (Current, {NUMERIC_INFORMATION}.type_no_limitation)
			Result := l_convertor.parsed_double
		end

	to_string_32: STRING_32
			-- Convert Current as a STRING_32.
			-- Was declared in READABLE_STRING_GENERAL as synonym of as_string_32.
			-- (from READABLE_STRING_GENERAL)
		local
			i, nb: INTEGER_32
		do
			if attached {STRING_32} Current as l_result then
				Result := l_result
			else
				nb := count
				create Result.make (nb);
				Result.set_count (nb)
				from
					i := 1
				until
					i > nb
				loop
					Result.put_code (code (i), i)
					i := i + 1
				end
			end
		ensure -- from READABLE_STRING_GENERAL
			as_string_32_not_void: Result /= Void
			identity: (conforms_to (create {STRING_32}.make_empty) and Result = Current) or (not conforms_to (create {STRING_32}.make_empty) and Result /= Current)
		end

	to_string_8: STRING_8
			-- Convert Current as a STRING_8.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			is_valid_as_string_8: Is_valid_as_string_8
		local
			i, nb: INTEGER_32
		do
			if attached {STRING_8} Current as s then
				Result := s
			else
				nb := count
				create Result.make (nb);
				Result.set_count (nb)
				from
					i := 1
				until
					i > nb
				loop
					check
						from_precondition: Result.valid_code (code (i))
					end;
					Result.put_code (code (i), i)
					i := i + 1
				end
			end
		ensure -- from READABLE_STRING_GENERAL
			as_string_8_not_void: Result /= Void
			identity: (conforms_to ("") and Result = Current) or (not conforms_to ("") and Result /= Current)
		end
	
feature -- Duplication

	frozen clone (other: detachable ANY): like other
		obsolete "Use `twin' instead. [2017-05-31]"
			-- Void if other is void; otherwise new object
			-- equal to other
			--
			-- For non-void other, clone calls copy;
			-- to change copying/cloning semantics, redefine copy.
			-- (from ANY)
		do
			if other /= Void then
				Result := other.twin
			end
		ensure -- from ANY
			instance_free: class
			equal: Result ~ other
		end

	copy (other: like Current)
			-- Reinitialize by copying the characters of other.
			-- (This is also used by twin.)
		require -- from ANY
			other_not_void: other /= Void
			type_identity: same_type (other)
		local
			old_area: like area
		do
			if other /= Current then
				old_area := area
				standard_copy (other)
				if old_area = Void or else old_area = other.area or else old_area.count <= count then
					area := area.resized_area (count + 1)
				else
					old_area.copy_data (area, 0, 0, count)
					area := old_area
				end
				internal_hash_code := 0
				internal_case_insensitive_hash_code := 0
			end
		ensure -- from ANY
			is_equal: Current ~ other
		ensure then
			new_result_count: count = other.count
		end

	frozen deep_clone (other: detachable ANY): like other
		obsolete "Use `deep_twin' instead. [2017-05-31]"
			-- Void if other is void: otherwise, new object structure
			-- recursively duplicated from the one attached to other
			-- (from ANY)
		do
			if other /= Void then
				Result := other.deep_twin
			end
		ensure -- from ANY
			instance_free: class
			deep_equal: deep_equal (other, Result)
		end

	frozen deep_copy (other: READABLE_STRING_8)
			-- Effect equivalent to that of:
			--		copy (other . deep_twin)
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		do
			copy (other.deep_twin)
		ensure -- from ANY
			deep_equal: deep_equal (Current, other)
		end

	frozen deep_twin: READABLE_STRING_8
			-- New object structure recursively duplicated from Current.
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			deep_twin_not_void: Result /= Void
			deep_equal: deep_equal (Current, Result)
		end

	head (n: INTEGER_32): READABLE_STRING_8
			-- Prefix, retaining first n characters (or as many as available).
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			non_negative_argument: n >= 0
		do
			if n > count then
				Result := twin
			else
				Result := substring (1, n)
			end
		ensure -- from READABLE_STRING_GENERAL
			same_count: count = old count
			new_count: Result.count = n.min (count)
		end

	frozen standard_clone (other: detachable ANY): like other
		obsolete "Use `standard_twin' instead. [2017-05-31]"
			-- Void if other is void; otherwise new object
			-- field-by-field identical to other.
			-- Always uses default copying semantics.
			-- (from ANY)
		do
			if other /= Void then
				Result := other.standard_twin
			end
		ensure -- from ANY
			instance_free: class
			equal: standard_equal (Result, other)
		end

	frozen standard_copy (other: READABLE_STRING_8)
			-- Copy every field of other onto corresponding field
			-- of current object.
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
			type_identity: same_type (other)
		external
			"built_in"
		ensure -- from ANY
			is_standard_equal: standard_is_equal (other)
		end

	frozen standard_twin: READABLE_STRING_8
			-- New object field-by-field identical to other.
			-- Always uses default copying semantics.
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			standard_twin_not_void: Result /= Void
			equal: standard_equal (Result, Current)
		end

	substring (start_index, end_index: INTEGER_32): like Current
			-- Copy of substring containing all characters at indices
			-- between start_index and end_index
		deferred
		ensure -- from READABLE_STRING_GENERAL
			substring_not_void: Result /= Void
			substring_count: Result.count = end_index - start_index + 1 or Result.count = 0
			first_code: Result.count > 0 implies Result.character_32_item (1) = character_32_item (start_index)
			recurse: Result.count > 0 implies Result.substring (2, Result.count) ~ substring (start_index + 1, end_index)
		end

	tail (n: INTEGER_32): READABLE_STRING_8
			-- Suffix, retaining last n characters (or as many as available).
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			non_negative_argument: n >= 0
		do
			if n > count then
				Result := twin
			else
				Result := substring (count - n + 1, count)
			end
		ensure -- from READABLE_STRING_GENERAL
			same_count: count = old count
			new_count: Result.count = n.min (count)
		end

	frozen twin: READABLE_STRING_8
			-- New object equal to Current
			-- twin calls copy; to change copying/twinning semantics, redefine copy.
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			twin_not_void: Result /= Void
			is_equal: Result ~ Current
		end
	
feature -- Basic operations

	frozen as_attached: attached READABLE_STRING_8
		obsolete "Remove calls to this feature. [2017-05-31]"
			-- Attached version of Current.
			-- (Can be used during transitional period to convert
			-- non-void-safe classes to void-safe ones.)
			-- (from ANY)
		do
			Result := Current
		end

	frozen default: detachable READABLE_STRING_8
			-- Default value of object's type
			-- (from ANY)
		do
		end

	frozen default_pointer: POINTER
			-- Default value of type POINTER
			-- (Avoid the need to write p.default for
			-- some p of type POINTER.)
			-- (from ANY)
		do
		ensure -- from ANY
			instance_free: class
		end

	default_rescue
			-- Process exception for routines with no Rescue clause.
			-- (Default: do nothing.)
			-- (from ANY)
		do
		end

	frozen do_nothing
			-- Execute a null action.
			-- (from ANY)
		do
		ensure -- from ANY
			instance_free: class
		end

	plus alias "+" (s: READABLE_STRING_8): like Current
			-- Concatenation with s.
		require
			argument_attached: attached s
		deferred
		ensure
			plus_attached: attached Result
			new_count: Result.count = count + s.count
			initial: Elks_checking implies Result.substring (1, count) ~ Current
			final: Elks_checking implies Result.substring (count + 1, count + s.count).same_string (s)
		end
	
feature {NONE} -- Implementation

	C_string_provider: C_STRING
			-- To create Eiffel strings from C string.
			-- (from READABLE_STRING_GENERAL)
		once
			create Result.make_empty (0)
		ensure -- from READABLE_STRING_GENERAL
			c_string_provider_not_void: Result /= Void
		end

	Character_properties: CHARACTER_PROPERTY
			-- Access to Unicode character properties
			-- (from READABLE_STRING_GENERAL)
		once
			create Result.make
		end

	Ctoi_convertor: STRING_TO_INTEGER_CONVERTOR
			-- Convertor used to convert string to integer or natural
			-- (from READABLE_STRING_GENERAL)
		once
			create Result.make;
			Result.set_leading_separators (" ");
			Result.set_trailing_separators (" ");
			Result.set_leading_separators_acceptable (True);
			Result.set_trailing_separators_acceptable (True)
		ensure -- from READABLE_STRING_GENERAL
			ctoi_convertor_not_void: Result /= Void
		end

	Ctor_convertor: STRING_TO_REAL_CONVERTOR
			-- Convertor used to convert string to real or double
			-- (from READABLE_STRING_GENERAL)
		once
			create Result.make;
			Result.set_leading_separators (" ");
			Result.set_trailing_separators (" ");
			Result.set_leading_separators_acceptable (True);
			Result.set_trailing_separators_acceptable (True)
		ensure -- from READABLE_STRING_GENERAL
			ctor_convertor_not_void: Result /= Void
		end

	Dotnet_convertor: SYSTEM_STRING_FACTORY
			-- Convertor used to convert from and to SYSTEM_STRING.
			-- (from READABLE_STRING_GENERAL)
		once
			create Result
		ensure -- from READABLE_STRING_GENERAL
			dotnet_convertor_not_void: Result /= Void
		end

	is_valid_integer_or_natural (type: INTEGER_32): BOOLEAN
			-- Is Current a valid number according to given type?
			-- (from READABLE_STRING_GENERAL)
		local
			l_convertor: like Ctoi_convertor
		do
			l_convertor := Ctoi_convertor;
			l_convertor.reset (type);
			l_convertor.parse_string_with_type (Current, type)
			Result := l_convertor.is_integral_integer
		end

	mirror_area (a: like area; start_index, end_index: INTEGER_32)
			-- Mirror all characters in a between start_index and end_index.
		require
			a_not_void: a /= Void
			start_index_non_negative: start_index >= 0
			start_index_not_too_big: start_index <= end_index + 1
			end_index_valid: end_index < a.count
		local
			c: CHARACTER_8
			i, j: INTEGER_32
		do
			from
				i := end_index
			until
				i <= j
			loop
				c := a.item (i);
				a.put (a.item (j), i);
				a.put (c, j)
				i := i - 1
				j := j + 1
			end
		end

	new_string (n: INTEGER_32): READABLE_STRING_8
			-- New instance of current with space for at least n characters.
			-- (from READABLE_STRING_GENERAL)
		require -- from READABLE_STRING_GENERAL
			n_non_negative: n >= 0
		deferred
		ensure -- from READABLE_STRING_GENERAL
			new_string_not_void: Result /= Void
			new_string_empty: Result.is_empty
			new_string_area_big_enough: Result.capacity >= n
		end

	str_strict_cmp (this, other: like area; this_index, other_index, n: INTEGER_32): INTEGER_32
			-- Compare n characters from this starting at this_index with
			-- n characters from and other starting at other_index.
			-- 0 if equal, < 0 if this < other,
			-- > 0 if this > other
		require
			this_not_void: this /= Void
			other_not_void: other /= Void
			n_non_negative: n >= 0
			n_valid: n <= (this.upper - this_index + 1) and n <= (other.upper - other_index + 1)
		local
			i, j, nb, l_current_code, l_other_code: INTEGER_32
		do
			from
				i := this_index
				nb := i + n
				j := other_index
			until
				i = nb
			loop
				l_current_code := this.item (i).code
				l_other_code := other.item (j).code
				if l_current_code /= l_other_code then
					Result := l_current_code - l_other_code
					i := nb - 1
				end
				i := i + 1
				j := j + 1
			end
		end

	String_searcher: STRING_8_SEARCHER
			-- String searcher specialized for READABLE_STRING_8 instances.
		once
			create Result.make
		ensure -- from READABLE_STRING_GENERAL
			string_searcher_not_void: Result /= Void
		end

	to_lower_area (a: like area; start_index, end_index: INTEGER_32)
			-- Replace all characters in a between start_index and end_index
			-- with their lower version.
		require
			a_not_void: a /= Void
			start_index_non_negative: start_index >= 0
			start_index_not_too_big: start_index <= end_index + 1
			end_index_valid: end_index < a.count
		local
			i: INTEGER_32
		do
			from
				i := start_index
			until
				i > end_index
			loop
				a.put (a.item (i).lower, i)
				i := i + 1
			end
		end

	to_upper_area (a: like area; start_index, end_index: INTEGER_32)
			-- Replace all characters in a between start_index and end_index
			-- with their upper version.
		require
			a_not_void: a /= Void
			start_index_non_negative: start_index >= 0
			start_index_not_too_big: start_index <= end_index + 1
			end_index_valid: end_index < a.count
		local
			i: INTEGER_32
		do
			from
				i := start_index
			until
				i > end_index
			loop
				a.put (a.item (i).upper, i)
				i := i + 1
			end
		end
	
feature {READABLE_STRING_8, READABLE_STRING_32, STRING_8_SEARCHER, STRING_32_SEARCHER, HEXADECIMAL_STRING_TO_INTEGER_CONVERTER, STRING_TO_INTEGER_CONVERTOR, STRING_TO_REAL_CONVERTOR, STRING_8_ITERATION_CURSOR, IO_MEDIUM} -- Implementation

	area: SPECIAL [CHARACTER_8]
			-- Storage for characters.

	area_lower: INTEGER_32
			-- Minimum index.
		do
		ensure
			area_lower_non_negative: Result >= 0
			area_lower_valid: Result <= area.upper
		end

	area_upper: INTEGER_32
			-- Maximum index.
		do
			Result := area_lower + count - 1
		ensure
			area_upper_valid: Result <= area.upper
			area_upper_in_bound: area_lower <= Result + 1
		end
	
feature {READABLE_STRING_GENERAL} -- Implementation

	internal_case_insensitive_hash_code: INTEGER_32
			-- Cash for case_insensitive_hash_code.
			-- (from READABLE_STRING_GENERAL)

	internal_hash_code: INTEGER_32
			-- Cache for hash_code.
			-- (from READABLE_STRING_GENERAL)
	
feature -- Access: Cursor

	new_character_32_cursor: STRING_ITERATION_CURSOR
			-- Fresh cursor for this string that iterates over code points (see code)
			-- exposed as CHARACTER_32.
			-- (from READABLE_STRING_GENERAL)
		do
			create Result.make (Current);
			Result.start
		end
	
feature {NONE} -- Assertion helper

	Elks_checking: BOOLEAN = False
			-- Are ELKS checkings verified? Must be True when changing implementation of STRING_GENERAL or descendant.
			-- (from READABLE_STRING_GENERAL)
	
feature -- Output

	Io: STD_FILES
			-- Handle to standard file setup
			-- (from ANY)
		once
			create Result;
			Result.set_output_default
		ensure -- from ANY
			instance_free: class
			io_not_void: Result /= Void
		end

	out: STRING_8
			-- New string containing terse printable representation
			-- of current object
		require -- from  ANY
			True
		do
			create Result.make (count);
			Result.append_string_general (Current)
		ensure -- from ANY
			out_not_void: Result /= Void
		ensure then
			out_not_void: Result /= Void
			same_items: same_type ("") implies Result.same_string_general (Current)
		end

	print (o: detachable ANY)
			-- Write terse external representation of o
			-- on standard output.
			-- (from ANY)
		local
			s: READABLE_STRING_8
		do
			if attached o then
				s := o.out
				if attached {READABLE_STRING_32} s as s32 then
					Io.put_string_32 (s32)
				elseif attached {READABLE_STRING_8} s as s8 then
					Io.put_string (s8)
				else
					Io.put_string_32 (s.as_string_32)
				end
			end
		ensure -- from ANY
			instance_free: class
		end

	frozen tagged_out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			tagged_out_not_void: Result /= Void
		end
	
feature -- Platform

	Operating_environment: OPERATING_ENVIRONMENT
			-- Objects available from the operating system
			-- (from ANY)
		once
			create Result
		ensure -- from ANY
			instance_free: class
			operating_environment_not_void: Result /= Void
		end
	
feature {NONE} -- Retrieval

	frozen internal_correct_mismatch
			-- Called from runtime to perform a proper dynamic dispatch on correct_mismatch
			-- from MISMATCH_CORRECTOR.
			-- (from ANY)
		local
			l_msg: STRING_32
			l_exc: EXCEPTIONS
		do
			if attached {MISMATCH_CORRECTOR} Current as l_corrector then
				l_corrector.correct_mismatch
			else
				create l_msg.make_from_string ("Mismatch: ".as_string_32)
				create l_exc;
				l_msg.append (generating_type.name_32);
				l_exc.raise_retrieval_exception (l_msg)
			end
		end
	
invariant
	area_not_void: area /= Void

		-- from COMPARABLE
	irreflexive_comparison: not (Current < Current)

		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

		-- from READABLE_INDEXABLE
	consistent_boundaries: Lower <= count or else Lower = count + 1

note
	copyright: "Copyright (c) 1984-2020, 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 -- class READABLE_STRING_8

Generated by ISE EiffelStudio