Changeset 31185 in project for wiki/eggref/4/utf8


Ignore:
Timestamp:
08/02/14 14:04:17 (6 years ago)
Author:
sjamaan
Message:

Add an example on how to rename byte string operations (so we can close #1143)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/utf8

    r31107 r31185  
    198198can directly access bytes, such as if you were implementing your own
    199199regex library or text buffer and wanted optimal performance. For
    200 these cases we have renamed the original primitives by replacing
    201 {{string}} with {{byte-string}}. Thus {{byte-string-length}} is the
    202 length in bytes, not characters, of the strings (the equivalent of
    203 Gauche's {{string-size}}). {{byte-string-set!}} can corrupt the UTF-8
    204 encoding and should be used sparingly if at all.
     200these cases you can simply import and rename or prefix the string
     201procedures from the {{scheme}} module, like so:
     202
     203<enscript highlight="scheme">
     204(use utf8)
     205(import (rename (only scheme string-ref string-set!)
     206                (string-ref byte-ref)
     207                (string-set! byte-set!)))
     208</encript>
     209
     210Now, the original string operations which operate at the byte level
     211are available as {{byte-ref}} and {{byte-set!}}.
    205212
    206213==== Low-level API
Note: See TracChangeset for help on using the changeset viewer.