+ if from > _length then return ""
+ if from < 0 then from = 0
+ return substring(from, _length)
+ end
+
+ redef fun has_substring(str: String, pos: Int): Bool
+ do
+ var itsindex = str._length - 1
+
+ var myindex = pos + itsindex
+ var myitems = _items
+
+ var itsitems = str._items
+
+ if myindex > _length or itsindex > myindex then return false
+
+ var itsindexfrom = str.index_from
+ itsindex += itsindexfrom
+ myindex += index_from
+
+ while itsindex >= itsindexfrom do
+ if myitems[myindex] != itsitems[itsindex] then return false
+ myindex -= 1
+ itsindex -= 1
+ end
+
+ return true
+ end
+
+ redef fun to_upper: String
+ do
+ var outstr = calloc_string(self._length + 1)
+ var out_index = 0
+
+ var myitems = self._items
+ var index_from = self._index_from
+ var max = self._index_to
+
+ while index_from <= max do
+ outstr[out_index] = myitems[index_from].to_upper
+ out_index += 1
+ index_from += 1
+ end
+
+ outstr[self.length] = '\0'
+
+ return outstr.to_s_with_length(self._length)
+ end
+
+ redef fun to_lower : String
+ do
+ var outstr = calloc_string(self._length + 1)
+ var out_index = 0
+
+ var myitems = self._items
+ var index_from = self._index_from
+ var max = self._index_to
+
+ while index_from <= max do
+ outstr[out_index] = myitems[index_from].to_lower
+ out_index += 1
+ index_from += 1
+ end
+
+ outstr[self.length] = '\0'
+
+ return outstr.to_s_with_length(self._length)
+ end
+
+ redef fun trim: String
+ do
+ if self._length == 0 then return self
+ # find position of the first non white space char (ascii < 32) from the start of the string
+ var start_pos = self._index_from
+ while _items[start_pos].ascii <= 32 do
+ start_pos += 1
+ if start_pos == _index_to + 1 then return ""
+ end
+ # find position of the first non white space char from the end of the string
+ var end_pos = _index_to
+ while _items[end_pos].ascii <= 32 do
+ end_pos -= 1
+ if end_pos == start_pos then return _items[start_pos].to_s
+ end
+ start_pos -= index_from
+ end_pos -= index_from
+ return self.substring(start_pos, end_pos - start_pos + 1)
+ end
+
+ redef fun output
+ do
+ var i = self._index_from
+ var imax = self._index_to
+ while i <= imax do
+ _items[i].output
+ i += 1
+ end
+ end
+
+ ##################################################
+ # String Specific Methods #
+ ##################################################
+
+ # Creates a String object as a substring of another String
+ #
+ # From : index to start at
+ #
+ # To : Index to stop at (from + count -1)
+ #
+ private init from_substring(from: Int, to: Int, internalString: NativeString)
+ do
+ _items = internalString
+ _index_from = from
+ _index_to = to
+ _length = to - from + 1
+ end
+
+ private init with_infos(items: NativeString, len: Int, from: Int, to: Int)
+ do
+ self._items = items
+ _length = len
+ _index_from = from
+ _index_to = to