 : hex% ( n -- )
     CHAR: % , >hex >upper 2 CHAR: 0 pad-head % ;
 
-: push-utf8 ( ch -- )
+: hex-utf8% ( ch -- )
     1string utf8 encode [ hex% ] each ;
 
 : (url-encode) ( str quot: ( ch -- ? ) -- encoded )

! Copyright (C) 2008, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: arrays ascii assocs byte-arrays combinators
combinators.short-circuit fry io.encodings.string
io.encodings.utf8 kernel linked-assocs make math math.parser
present sequences splitting strings ;
IN: urls.encoding

: url-quotable? ( ch -- ? )

            '[ dup @ [ , ] [ hex% ] if ] each
        ] [
            [ present ] dip
            '[ dup @ [ , ] [ hex-utf8% ] if ] each
        ] if
    ] "" make ; inline

