Menu

#5 add make_from_string_general to UC_UTF8_STRING

Next_Release
closed
kernel (2)
5
2008-11-17
2008-05-10
No

Message from Colin Adams in the gobo-eiffel-develop mailing list on April 21st 2008:

[gobo-eiffel-develop] Code to create a UC_UTF8_STRING from STRING_GENERAL

Here is the functional version. It should be straight-forward to
change it to a creation procedure.

Note that it is liberal on the memory creation of l_bytes, to avoid
any resizing of this buffer.

utf8\_string \(a\_string: STRING\_GENERAL\): UC\_UTF8\_STRING is
        \-- UTF-8 encoded version of \`a\_string'
    require
        a\_string\_not\_void: a\_string /= Void
    local
        i: INTEGER\_32
        l\_bytes: STRING            
    do
        create l\_bytes.make \(a\_string.count \* 4\)
        from
            i := 1
        until
            i > a\_string.count
        loop
            utf8.append\_code\_to\_utf8 \(l\_bytes, a\_string.code \(i\).as\_integer\_32\)
            i := i + 1
        end
        create Result.make\_from\_utf8 \(l\_bytes\)
    ensure
        utf8\_string\_not\_void: Result /= Void
        correct\_count: Result.count = a\_string.count
        strings\_equal: True -- can't be checked as STRING\_GENERAL and

UC_STRING lack the facilities (`for_all')
end

Discussion

  • Eric Bezault

    Eric Bezault - 2008-05-10

    Logged In: YES
    user_id=13278
    Originator: YES

    Colin Adams wrote:

    On 21/04/2008, Eric Bezault <ericb@gobosoft.com> wrote:
    >> After looking at class UC_STRING, I'm wondering whether we should
    >> just adapt the routines `make_from_string' and `make_from_substring'
    >> so that we can pass a STRING_GENERAL. Perhaps we will have to
    >> rename the version of `make_from_string' inherited from STRING.
    >> Or add `make_from_string_general', `make_from_substring_general',
    >> make `make_from_substring' obsolete (make it call
    >> `make_from_substring_general') and modify `make_from_string'
    >> to call `make_from_string_general'. I'm not sure what the best
    >> naming convention is.

    I think the last suggestion (adding make_from_string_general and
    changing make_from_string to call make_from_string_general, etc.) is
    best.

     
  • Eric Bezault

    Eric Bezault - 2008-11-17
    • status: open --> closed
     
  • Eric Bezault

    Eric Bezault - 2008-11-17

    Implemented in Gobo 3.9.

     

Log in to post a comment.