Ergebnis für URL: http://www.gnu.org/software/guile/manual/html_node/Representing-Strings-as-Bytes.html#index-character-encoding #[1]Top [2]Concept Index [3]Table of Contents [4]Strings [5]Conversion to/from C
[6]Miscellaneous String Operations
Next: [7]Conversion to/from C, Previous: [8]Miscellaneous String Operations, Up:
[9]Strings [[10]Contents][[11]Index]
____________________________________________________________________________
6.6.5.13 Representing Strings as Bytes
Out in the cold world outside of Guile, not all strings are treated in the same
way. Out there there are only bytes, and there are many ways of representing a
strings (sequences of characters) as binary data (sequences of bytes).
As a user, usually you don't have to think about this very much. When you type on
your keyboard, your system encodes your keystrokes as bytes according to the
locale that you have configured on your computer. Guile uses the locale to decode
those bytes back into characters - hopefully the same characters that you typed
in.
All is not so clear when dealing with a system with multiple users, such as a web
server. Your web server might get a request from one user for data encoded in the
ISO-8859-1 character set, and then another request from a different user for
UTF-8 data.
Guile provides an iconv module for converting between strings and sequences of
bytes. See [12]Bytevectors, for more on how Guile represents raw byte sequences.
This module gets its name from the common UNIX command of the same name.
Note that often it is sufficient to just read and write strings from ports
instead of using these functions. To do this, specify the port encoding using
set-port-encoding!. See [13]Ports, for more on ports and character encodings.
Unlike the rest of the procedures in this section, you have to load the iconv
module before having access to these procedures:
(use-modules (ice-9 iconv))
Scheme Procedure: string->bytevector string encoding [conversion-strategy][14] ¶
Encode string as a sequence of bytes.
The string will be encoded in the character set specified by the encoding
string. If the string has characters that cannot be represented in the
encoding, by default this procedure raises an encoding-error. Pass a
conversion-strategy argument to specify other behaviors.
The return value is a bytevector. See [15]Bytevectors, for more on
bytevectors. See [16]Ports, for more on character encodings and conversion
strategies.
Scheme Procedure: bytevector->string bytevector encoding
[conversion-strategy][17] ¶
Decode bytevector into a string.
The bytes will be decoded from the character set by the encoding string.
If the bytes do not form a valid encoding, by default this procedure
raises an decoding-error. As with string->bytevector, pass the optional
conversion-strategy argument to modify this behavior. See [18]Ports, for
more on character encodings and conversion strategies.
Scheme Procedure: call-with-output-encoded-string encoding proc
[conversion-strategy][19] ¶
Like call-with-output-string, but instead of returning a string, returns a
encoding of the string according to encoding, as a bytevector. This
procedure can be more efficient than collecting a string and then
converting it via string->bytevector.
____________________________________________________________________________
Next: [20]Conversion to/from C, Previous: [21]Miscellaneous String Operations,
Up: [22]Strings [[23]Contents][[24]Index]
References
1. http://www.gnu.org/software/guile/manual/html_node/index.html
2. http://www.gnu.org/software/guile/manual/html_node/Concept-Index.html
3. http://www.gnu.org/software/guile/manual/html_node/index.html#SEC_Contents
4. http://www.gnu.org/software/guile/manual/html_node/Strings.html
5. http://www.gnu.org/software/guile/manual/html_node/Conversion-to_002ffrom-C.html
6. http://www.gnu.org/software/guile/manual/html_node/Miscellaneous-String-Operations.html
7. http://www.gnu.org/software/guile/manual/html_node/Conversion-to_002ffrom-C.html
8. http://www.gnu.org/software/guile/manual/html_node/Miscellaneous-String-Operations.html
9. http://www.gnu.org/software/guile/manual/html_node/Strings.html
10. http://www.gnu.org/software/guile/manual/html_node/index.html#SEC_Contents
11. http://www.gnu.org/software/guile/manual/html_node/Concept-Index.html
12. http://www.gnu.org/software/guile/manual/html_node/Bytevectors.html
13. http://www.gnu.org/software/guile/manual/html_node/Ports.html
14. http://www.gnu.org/software/guile/manual/html_node/Representing-Strings-as-Bytes.html#index-string_002d_003ebytevector
15. http://www.gnu.org/software/guile/manual/html_node/Bytevectors.html
16. http://www.gnu.org/software/guile/manual/html_node/Ports.html
17. http://www.gnu.org/software/guile/manual/html_node/Representing-Strings-as-Bytes.html#index-bytevector_002d_003estring
18. http://www.gnu.org/software/guile/manual/html_node/Ports.html
19. http://www.gnu.org/software/guile/manual/html_node/Representing-Strings-as-Bytes.html#index-call_002dwith_002doutput_002dencoded_002dstring
20. http://www.gnu.org/software/guile/manual/html_node/Conversion-to_002ffrom-C.html
21. http://www.gnu.org/software/guile/manual/html_node/Miscellaneous-String-Operations.html
22. http://www.gnu.org/software/guile/manual/html_node/Strings.html
23. http://www.gnu.org/software/guile/manual/html_node/index.html#SEC_Contents
24. http://www.gnu.org/software/guile/manual/html_node/Concept-Index.html
Usage: http://www.kk-software.de/kklynxview/get/URL
e.g. http://www.kk-software.de/kklynxview/get/http://www.kk-software.de
Errormessages are in German, sorry ;-)