diff --git a/core/io/encodings/string/string.factor b/core/io/encodings/string/string.factor new file mode 100644 index 0000000000..acfe2edd89 --- /dev/null +++ b/core/io/encodings/string/string.factor @@ -0,0 +1,5 @@ +USING: io.encodings io io.streams.byte-array ; +IN: io.encodings.string + +: decode-string ( byte-array encoding -- string ) + contents ; diff --git a/extra/http/http.factor b/extra/http/http.factor index 35fe3ce544..7ed921480c 100755 --- a/extra/http/http.factor +++ b/extra/http/http.factor @@ -2,9 +2,9 @@ ! See http://factorcode.org/license.txt for BSD license. USING: hashtables io io.streams.string kernel math namespaces math.parser assocs sequences strings splitting ascii -io.encodings.utf8 namespaces unicode.case combinators -vectors sorting new-slots accessors calendar calendar.format -quotations arrays ; +io.encodings.utf8 io.encodings io.encodings.string namespaces +unicode.case combinators vectors sorting new-slots accessors +calendar calendar.format quotations arrays ; IN: http : http-port 80 ; inline @@ -18,7 +18,7 @@ IN: http swap "/_-." member? or ; foldable : push-utf8 ( ch -- ) - 1string encode-utf8 [ CHAR: % , >hex 2 CHAR: 0 pad-left % ] each ; + 1string utf8 encode-string [ CHAR: % , >hex 2 CHAR: 0 pad-left % ] each ; : url-encode ( str -- str ) [ [ @@ -50,7 +50,7 @@ IN: http ] if ; : url-decode ( str -- str ) - [ 0 swap url-decode-iter ] "" make decode-utf8 ; + [ 0 swap url-decode-iter ] "" make utf8 decode-string ; : crlf "\r\n" write ; diff --git a/extra/ui/x11/x11.factor b/extra/ui/x11/x11.factor index 1fec668717..ae56c6a43f 100755 --- a/extra/ui/x11/x11.factor +++ b/extra/ui/x11/x11.factor @@ -3,7 +3,7 @@ USING: alien alien.c-types arrays ui ui.gadgets ui.gestures ui.backend ui.clipboards ui.gadgets.worlds assocs kernel math namespaces opengl sequences strings x11.xlib x11.events x11.xim -x11.glx x11.clipboard x11.constants x11.windows +x11.glx x11.clipboard x11.constants x11.windows io.encodings io.encodings.utf8 combinators debugger system command-line ui.render math.vectors tuples opengl.gl threads ; IN: ui.x11 @@ -137,7 +137,7 @@ M: world selection-notify-event : encode-clipboard ( string type -- bytes ) XSelectionRequestEvent-target XA_UTF8_STRING = - [ encode-utf8 ] [ string>char-alien ] if ; + [ utf8 encode-string ] [ string>char-alien ] if ; : set-selection-prop ( evt -- ) dpy get swap @@ -212,7 +212,7 @@ M: x-clipboard paste-clipboard : set-title-new ( dpy window string -- ) >r XA_NET_WM_NAME XA_UTF8_STRING 8 PropModeReplace - r> encode-utf8 dup length XChangeProperty drop ; + r> utf8 encode-string dup length XChangeProperty drop ; M: x11-ui-backend set-title ( string world -- ) world-handle x11-handle-window swap dpy get -rot diff --git a/extra/x11/clipboard/clipboard.factor b/extra/x11/clipboard/clipboard.factor index eb4191ebb1..b839e262d9 100755 --- a/extra/x11/clipboard/clipboard.factor +++ b/extra/x11/clipboard/clipboard.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2006, 2007 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types alien.syntax arrays kernel math -namespaces sequences io.encodings.utf8 x11.xlib x11.constants ; +namespaces sequences io.encodings.string io.encodings.utf8 x11.xlib +x11.constants ; IN: x11.clipboard ! This code was based on by McCLIM's Backends/CLX/port.lisp @@ -35,7 +36,7 @@ TUPLE: x-clipboard atom contents ; >r XSelectionEvent-property zero? [ r> drop f ] [ - r> selection-property 1 window-property decode-utf8 + r> selection-property 1 window-property utf8 decode-string ] if ; : own-selection ( prop win -- )