Replacing encode/decode-utf8 with utf8 encode/decode-string

db4
Daniel Ehrenberg 2008-03-05 17:41:25 -06:00
parent 5805db7ac4
commit e06885550e
4 changed files with 16 additions and 10 deletions

View File

@ -0,0 +1,5 @@
USING: io.encodings io io.streams.byte-array ;
IN: io.encodings.string
: decode-string ( byte-array encoding -- string )
<byte-reader> contents ;

View File

@ -2,9 +2,9 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: hashtables io io.streams.string kernel math namespaces USING: hashtables io io.streams.string kernel math namespaces
math.parser assocs sequences strings splitting ascii math.parser assocs sequences strings splitting ascii
io.encodings.utf8 namespaces unicode.case combinators io.encodings.utf8 io.encodings io.encodings.string namespaces
vectors sorting new-slots accessors calendar calendar.format unicode.case combinators vectors sorting new-slots accessors
quotations arrays ; calendar calendar.format quotations arrays ;
IN: http IN: http
: http-port 80 ; inline : http-port 80 ; inline
@ -18,7 +18,7 @@ IN: http
swap "/_-." member? or ; foldable swap "/_-." member? or ; foldable
: push-utf8 ( ch -- ) : 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 ) : url-encode ( str -- str )
[ [ [ [
@ -50,7 +50,7 @@ IN: http
] if ; ] if ;
: url-decode ( str -- str ) : 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 ; : crlf "\r\n" write ;

View File

@ -3,7 +3,7 @@
USING: alien alien.c-types arrays ui ui.gadgets ui.gestures USING: alien alien.c-types arrays ui ui.gadgets ui.gestures
ui.backend ui.clipboards ui.gadgets.worlds assocs kernel math ui.backend ui.clipboards ui.gadgets.worlds assocs kernel math
namespaces opengl sequences strings x11.xlib x11.events x11.xim 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 io.encodings.utf8 combinators debugger system command-line
ui.render math.vectors tuples opengl.gl threads ; ui.render math.vectors tuples opengl.gl threads ;
IN: ui.x11 IN: ui.x11
@ -137,7 +137,7 @@ M: world selection-notify-event
: encode-clipboard ( string type -- bytes ) : encode-clipboard ( string type -- bytes )
XSelectionRequestEvent-target XA_UTF8_STRING = XSelectionRequestEvent-target XA_UTF8_STRING =
[ encode-utf8 ] [ string>char-alien ] if ; [ utf8 encode-string ] [ string>char-alien ] if ;
: set-selection-prop ( evt -- ) : set-selection-prop ( evt -- )
dpy get swap dpy get swap
@ -212,7 +212,7 @@ M: x-clipboard paste-clipboard
: set-title-new ( dpy window string -- ) : set-title-new ( dpy window string -- )
>r >r
XA_NET_WM_NAME XA_UTF8_STRING 8 PropModeReplace 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 -- ) M: x11-ui-backend set-title ( string world -- )
world-handle x11-handle-window swap dpy get -rot world-handle x11-handle-window swap dpy get -rot

View File

@ -1,7 +1,8 @@
! Copyright (C) 2006, 2007 Slava Pestov ! Copyright (C) 2006, 2007 Slava Pestov
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.syntax arrays kernel math 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 IN: x11.clipboard
! This code was based on by McCLIM's Backends/CLX/port.lisp ! 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 XSelectionEvent-property zero? [
r> drop f r> drop f
] [ ] [
r> selection-property 1 window-property decode-utf8 r> selection-property 1 window-property utf8 decode-string
] if ; ] if ;
: own-selection ( prop win -- ) : own-selection ( prop win -- )