Skip to content

Commit dcf45d4

Browse files
README: add basic using info
1 parent 2725e47 commit dcf45d4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,22 @@
55

66
[![Julia 0.4 Status](http://pkg.julialang.org/badges/LegacyStrings_0.4.svg)](http://pkg.julialang.org/?pkg=LegacyStrings&ver=0.4)
77
[![Julia 0.5 Status](http://pkg.julialang.org/badges/LegacyStrings_0.5.svg)](http://pkg.julialang.org/?pkg=LegacyStrings&ver=0.5)
8+
9+
The LegacyStrings package provides compatibility string types from Julia 0.4 (and earlier), which were removed in Julia 0.5, including:
10+
11+
- `ASCIIString`: a single-byte-per character string type that can only hold ASCII string data.
12+
- `UTF8String`: a string type with single byte code units (`UInt8`), encoding strings as UTF-8.
13+
- `UTF16String`: a string type with two-byte native-endian code units (`UInt16`), encoding strings as UTF-16.
14+
- `UTF32String`: a string type with four-byte native-endian code units (`UInt32`), encoding strings as UTF-32.
15+
- `ByteString`: a type alias for `Union{ASCIIString,UTF8String}`, i.e. strings that can be passed to C directly.
16+
- `WString`: an alias for `UTF16String` if `Cwchart_t` is two bytes (i.e. Windows) or `UTF32String` otherwise.
17+
18+
LegacyStrings also defines and exports converter functions for these types, i.e.:
19+
20+
- `ascii`: convert to `ASCIIString`; on 0.5 since `Base` exports an `ascii` function as well, you must explicitly do `import LegacyStrings: ascii` or write `LegacyStrings.ascii` in order to use this function rather than `Base.ascii`.
21+
- `utf8`: convert to `UTF8String`.
22+
- `utf16`: convert to `UTF16String`.
23+
- `utf32`: convert to `UTF32String`.
24+
- `wstring`: alias for `utf16` or `utf32` according to what `WString` is an alias to.
25+
26+
The definitions of the above types and functions are conditional on the version of Julia being used so that you can do `using LegacyStrings` unconditionally and be guaranteed that e.g. `LegacyStrings.ASCIIString` is an `ASCIIString` type that will behave as expect in Julia 0.4 or earlier.

0 commit comments

Comments
 (0)