: strip-encodings ( -- )
os unix? [
[
- P" resource:core/io/encodings/utf16/utf16.factor"
- P" resource:core/io/encodings/utf16n/utf16n.factor" [ forget ] bi@
- "io.encodings.utf16"
- "io.encodings.utf16n" [ loaded-child-vocab-names [ forget-vocab ] each ] bi@
+ P" resource:core/io/encodings/utf16/utf16.factor" forget
+ "io.encodings.utf16" loaded-child-vocab-names [ forget-vocab ] each
] with-compilation-unit
] when ;
assocs cache classes colors combinators core-foundation
core-foundation.attributed-strings core-foundation.strings
core-graphics core-graphics.types core-text.fonts destructors
-fonts init io.encodings.string io.encodings.utf16n kernel make
+fonts init io.encodings.string io.encodings.utf16 kernel make
math math.functions math.order math.vectors namespaces opengl
sequences strings ;
IN: core-text
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.strings fry io.encodings.utf16n kernel
+USING: alien.strings fry io.encodings.utf16 kernel
splitting windows windows.kernel32 windows.types system
environment alien.data sequences windows.errors
io.streams.memory io.encodings io specialized-arrays ;
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.data arrays classes.struct
combinators continuations destructors fry io.backend
-io.encodings.string io.encodings.utf16n io.files.windows
+io.encodings.string io.encodings.utf16 io.files.windows
io.monitors io.pathnames io.ports kernel literals locals make
math sequences system threads windows.errors windows.kernel32
windows.types ;
USING: accessors alien alien.c-types alien.data alien.syntax
arrays byte-arrays classes.struct combinators.short-circuit
continuations destructors fry io io.encodings.string
-io.encodings.utf16n kernel literals locals math sequences
+io.encodings.utf16 kernel literals locals math sequences
strings system tools.ps windows.errors windows.handles
windows.kernel32 windows.ntdll windows.types ;
IN: tools.ps.windows
cocoa.pasteboard cocoa.runtime cocoa.subclassing cocoa.touchbar
cocoa.types cocoa.views combinators continuations
core-foundation.strings core-graphics core-graphics.types
-core-text debugger io.encodings.string io.encodings.utf16n
+core-text debugger io.encodings.string io.encodings.utf16
io.encodings.utf8 kernel literals math math.order math.parser
math.rectangles math.vectors namespaces opengl sequences
splitting threads ui.backend.cocoa.input-methods ui.commands
USING: accessors alien alien.c-types alien.data alien.strings
arrays ascii assocs assocs.extras byte-arrays calendar classes
classes.struct colors combinators continuations io io.crlf
-io.encodings.string io.encodings.utf16n io.encodings.utf8 kernel
+io.encodings.string io.encodings.utf16 io.encodings.utf8 kernel
libc literals make math math.bitwise namespaces sequences sets
specialized-arrays strings threads ui ui.backend ui.clipboards
ui.event-loop ui.gadgets ui.gadgets.private ui.gadgets.worlds
! Copyright (C) 2009, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors cache core-graphics.types core-text
-core-text.fonts io.encodings.string io.encodings.utf16n kernel
+core-text.fonts io.encodings.string io.encodings.utf16 kernel
math math.vectors namespaces opengl sequences ui.text
ui.text.private ;
IN: ui.text.core-text
! Copyright (C) 2017-2018 Alexander Ilin.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.data alien.libraries alien.strings
-init io.encodings.utf16n kernel literals math namespaces
+init io.encodings.utf16 kernel literals math namespaces
sequences ui.backend.windows ui.gadgets.worlds
ui.gestures windows.errors windows.messages windows.shell32
windows.types windows.user32 ;
! Copyright (C) 2010 Doug Coleman.
! Copyright (C) 2018 Alexander Ilin.
! See http://factorcode.org/license.txt for BSD license.
-USING: byte-arrays io.encodings.string io.encodings.utf16n
+USING: byte-arrays io.encodings.string io.encodings.utf16
kernel sequences tools.test windows.advapi32 windows.kernel32
windows.registry ;
IN: windows.registry.tests
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.data byte-arrays
classes.struct continuations io.encodings.string
-io.encodings.utf16n kernel literals locals math sequences sets
+io.encodings.utf16 kernel literals locals math sequences sets
splitting windows windows.advapi32 windows.errors
windows.kernel32 windows.time windows.types ;
IN: windows.registry
! Copyright (C) 2005, 2006 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types alien.syntax classes.struct colors
-io.encodings.utf16n io.encodings.utf8 kernel math math.bitwise
+io.encodings.utf16 io.encodings.utf8 kernel math math.bitwise
math.functions math.vectors sequences ;
FROM: alien.c-types => float short ;
IN: windows.types
USING: accessors alien.c-types alien.data arrays assocs
byte-arrays cache classes.struct colors combinators destructors
-fonts images init io.encodings.string io.encodings.utf16n kernel
+fonts images init io.encodings.string io.encodings.utf16 kernel
literals locals math math.bitwise math.functions namespaces
sequences specialized-arrays windows.errors windows.fonts
windows.gdi32 windows.offscreen windows.ole32 windows.types
USING: alien.accessors alien.c-types alien.libraries
alien.strings alien.syntax byte-arrays cpu.x86 eval help.markup
-help.syntax io io.backend io.encodings.utf16n io.encodings.utf8
+help.syntax io io.backend io.encodings.utf16 io.encodings.utf8
kernel math quotations sequences system ;
IN: alien
USING: alien alien.data alien.strings io.encodings.ascii
io.encodings.latin1 io.encodings.string io.encodings.utf16
-io.encodings.utf16n io.encodings.utf8 kernel libc tools.test ;
+io.encodings.utf8 kernel libc tools.test ;
{ "\u0000ff" }
[ "\u0000ff" latin1 string>alien latin1 alien>string ]
! Copyright (C) 2008, 2011 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien arrays byte-arrays byte-vectors init io
-io.encodings io.encodings.ascii io.encodings.utf16n
+io.encodings io.encodings.ascii io.encodings.utf16
io.encodings.utf8 io.streams.memory kernel kernel.private math
namespaces sequences sequences.private strings strings.private
system system.private ;
IN: io.encodings.utf16
ARTICLE: "io.encodings.utf16" "UTF-16 encoding"
-"The UTF-16 encoding is a variable-width encoding. Unicode code points are encoded as 2 or 4 byte sequences. There are three encoding descriptor classes for working with UTF-16, depending on endianness or the presence of a BOM:"
+"The UTF-16 encoding is a variable-width encoding. Unicode code points are encoded as 2 or 4 byte sequences. There are four encoding descriptor classes for working with UTF-16, depending on endianness or the presence of a BOM:"
{ $subsections
utf16
utf16le
utf16be
+ utf16n
} ;
ABOUT: "io.encodings.utf16"
{ $class-description "The encoding descriptor for UTF-16, that is, UTF-16 with a byte order mark. This is the most useful for general input and output in UTF-16. Streams can be made which read or write wth this encoding." }
{ $see-also "encodings-introduction" } ;
-{ utf16 utf16le utf16be } related-words
+HELP: utf16n
+{ $class-description "The encoding descriptor for UTF-16 without a byte order mark in native endian order. This is useful mostly for FFI calls which take input of strings of the type " { $snippet "wchar_t*" } "." }
+{ $see-also "encodings-introduction" } ;
+
+{ utf16 utf16le utf16be utf16n } related-words
! Copyright (C) 2008 Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
-USING: arrays io.encodings.string io.encodings.utf16 strings
+USING: accessors alien.data arrays io.encodings.string
+io.encodings.utf16 io.streams.byte-array kernel strings
tools.test ;
+IN: io.encodings.utf16.tests
{ { CHAR: x } } [ B{ 0 CHAR: x } utf16be decode >array ] unit-test
{ { 0x1D11E } } [ B{ 0xD8 0x34 0xDD 0x1E } utf16be decode >array ] unit-test
{ B{ CHAR: a 0 CHAR: b 0 CHAR: c 0 } } [ "abc" utf16le encode ] unit-test
{ B{ 0 CHAR: a 0 CHAR: b 0 CHAR: c } } [ "abc" utf16be encode ] unit-test
+
+: correct-endian ( obj -- ? )
+ code>> little-endian? utf16le utf16be ? = ;
+
+{ t } [ B{ } utf16n <byte-reader> correct-endian ] unit-test
+{ t } [ utf16n <byte-writer> correct-endian ] unit-test
+
! Copyright (C) 2006, 2009 Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors byte-arrays io io.encodings kernel math
-math.private sequences sequences.private strings strings.private ;
+USING: accessors alien.accessors byte-arrays io io.encodings
+kernel math math.private sequences sequences.private strings
+strings.private ;
IN: io.encodings.utf16
SINGLETON: utf16be
drop bom-le over stream-write utf16le <encoder> ;
PRIVATE>
+
+SINGLETON: utf16n
+
+: choose-utf16-endian ( -- descriptor )
+ B{ 1 0 0 0 } 0 alien-unsigned-4 1 = utf16le utf16be ? ; foldable
+
+M: utf16n <decoder> drop choose-utf16-endian <decoder> ;
+
+M: utf16n <encoder> drop choose-utf16-endian <encoder> ;
+++ /dev/null
-Daniel Ehrenberg
+++ /dev/null
-UTF16 encoding with native byte order
+++ /dev/null
-USING: help.markup help.syntax ;
-IN: io.encodings.utf16n
-
-HELP: utf16n
-{ $class-description "The encoding descriptor for UTF-16 without a byte order mark in native endian order. This is useful mostly for FFI calls which take input of strings of the type wchar_t*" }
-{ $see-also "encodings-introduction" } ;
+++ /dev/null
-USING: accessors alien.data io.encodings.utf16
-io.encodings.utf16n io.streams.byte-array kernel tools.test ;
-IN: io.encodings.utf16n.tests
-
-: correct-endian ( obj -- ? )
- code>> little-endian? [ utf16le = ] [ utf16be = ] if ;
-
-{ t } [ B{ } utf16n <byte-reader> correct-endian ] unit-test
-{ t } [ utf16n <byte-writer> correct-endian ] unit-test
+++ /dev/null
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: io.encodings io.encodings.utf16 kernel alien.accessors ;
-IN: io.encodings.utf16n
-
-! Native-order UTF-16
-
-SINGLETON: utf16n
-
-: choose-utf16-endian ( -- descriptor )
- B{ 1 0 0 0 } 0 alien-unsigned-4 1 = utf16le utf16be ? ; foldable
-
-M: utf16n <decoder> drop choose-utf16-endian <decoder> ;
-
-M: utf16n <encoder> drop choose-utf16-endian <encoder> ;