Skip to content

Commit d102671

Browse files
authored
Merge pull request #47 from JuliaStrings/aa/bb
Use BinaryBuilder-provided binaries, switch CI to GHA
2 parents c5b3f9e + d74c52e commit d102671

File tree

8 files changed

+64
-232
lines changed

8 files changed

+64
-232
lines changed

.github/workflows/ci.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [master]
5+
tags: ["*"]
6+
pull_request:
7+
jobs:
8+
test:
9+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
version:
15+
- '1.3'
16+
- '1' # automatically expands to the latest stable 1.x release of Julia
17+
- 'nightly'
18+
os:
19+
- ubuntu-latest
20+
- macOS-latest
21+
- windows-latest
22+
arch:
23+
- x64
24+
- x86
25+
exclude:
26+
- os: macOS-latest
27+
arch: x86
28+
steps:
29+
- uses: actions/checkout@v2
30+
- uses: julia-actions/setup-julia@v1
31+
with:
32+
version: ${{ matrix.version }}
33+
arch: ${{ matrix.arch }}
34+
- uses: actions/cache@v1
35+
env:
36+
cache-name: cache-artifacts
37+
with:
38+
path: ~/.julia/artifacts
39+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
40+
restore-keys: |
41+
${{ runner.os }}-test-${{ env.cache-name }}-
42+
${{ runner.os }}-test-
43+
${{ runner.os }}-
44+
- uses: julia-actions/julia-buildpkg@v1
45+
- uses: julia-actions/julia-runtest@v1
46+
- uses: julia-actions/julia-processcoverage@v1
47+
- uses: codecov/codecov-action@v1
48+
with:
49+
file: lcov.info

.gitignore

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
*.jl.cov
22
*.jl.*.cov
33
*.jl.mem
4-
deps/builds
5-
deps/downloads
6-
deps/src
7-
deps/usr
8-
deps/deps.jl
9-
deps/build.log
10-
MANIFEST.TOML
4+
Manifest.toml

.travis.yml

-20
This file was deleted.

Project.toml

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
name = "StringEncodings"
22
uuid = "69024149-9ee7-55f6-a4c4-859efe599b68"
3-
version = "0.3.3"
3+
version = "0.3.4"
44

55
[deps]
6-
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
7-
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
6+
Libiconv_jll = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531"
87

98
[compat]
10-
BinaryProvider = "0.4.1, 0.5"
11-
julia = "0.7, 1"
9+
Libiconv_jll = "1.16"
10+
julia = "1.3"
1211

1312
[extras]
1413
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

README.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# StringEncodings
22

3-
[![Travis CI Build Status](https://travis-ci.org/JuliaStrings/StringEncodings.jl.svg?branch=master)](https://travis-ci.org/JuliaStrings/StringEncodings.jl)
4-
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/3gslhfg91isldnvq?svg=true)](https://ci.appveyor.com/project/nalimilan/stringencodings-jl)
5-
[![Coveralls Coverage Status](https://coveralls.io/repos/JuliaStrings/StringEncodings.jl/badge.svg?branch=master&service=github)](https://coveralls.io/github/JuliaStrings/StringEncodings.jl?branch=master)
3+
[![Build status](https://github.com/JuliaStrings/StringEncodings.jl/workflows/CI/badge.svg)](https://github.com/JuliaStrings/StringEncodings.jl/actions?query=workflow%3ACI+branch%3Amaster)
64
[![Codecov Coverage Status](http://codecov.io/github/JuliaStrings/StringEncodings.jl/coverage.svg?branch=master)](http://codecov.io/github/JuliaStrings/StringEncodings.jl?branch=master)
75

8-
This Julia package provides support for decoding and encoding texts between multiple character encodings. It is currently based on the iconv interface, and supports all major platforms using either the native iconv support or [GNU libiconv](https://www.gnu.org/software/libiconv/). In the future, native Julia support for major encodings will be added.
6+
This Julia package provides support for decoding and encoding texts between multiple character encodings. It is currently based on the iconv interface, and supports all major platforms using [GNU libiconv](https://www.gnu.org/software/libiconv/). In the future, native Julia support for major encodings will be added.
97

108
## Encoding and Decoding Strings
119
*Encoding* a refers to the process of converting a string (of any `AbstractString` type) to a sequence of bytes represented as a `Vector{UInt8}`. *Decoding* refers to the inverse process.
@@ -153,7 +151,3 @@ julia> read(s, String) # Decoding happens automatically here
153151
Do not forget to call `close` on `StringEncoder` and `StringDecoder` objects to finish the encoding process. For `StringEncoder`, this function calls `flush`, which writes any characters still in the buffer, and possibly some control sequences (for stateful encodings). For both `StringEncoder` and `StringDecoder`, `close` checks that there are no incomplete sequences left in the input stream, and raise an `IncompleteSequenceError` if that's the case. It will also free iconv resources immediately, instead of waiting for garbage collection.
154152

155153
Conversion currently raises an error if an invalid byte sequence is encountered in the input, or if some characters cannot be represented in the target enconding. It is not yet possible to ignore such characters or to replace them with a placeholder.
156-
157-
## Notes on Installation on Linux OS
158-
159-
Most Linux distributions provide `iconv` functionalities as part of the base operating system library `glibc`. In normal circumstances, no additional installation of `libiconv` should be required. If you observe such a behavior on your operating system, file an issue with OS details.

appveyor.yml

-42
This file was deleted.

deps/build.jl

-124
This file was deleted.

src/StringEncodings.jl

+8-26
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,7 @@
22

33
module StringEncodings
44

5-
using Libdl
6-
7-
# Load in `deps.jl`, complaining if it does not exist
8-
const depsjl_path = joinpath(dirname(@__FILE__), "..", "deps", "deps.jl")
9-
if !isfile(depsjl_path)
10-
error("iconv not installed properly, run Pkg.build(\"StringEncodings\"), restart Julia and try again")
11-
end
12-
include(depsjl_path)
13-
14-
# Module initialization function
15-
function __init__()
16-
# Always check dependencies from `deps.jl`
17-
check_deps()
18-
end
5+
using Libiconv_jll
196

207
using Base.Libc: errno, strerror, E2BIG, EINVAL, EILSEQ
218

@@ -75,13 +62,13 @@ show(io::IO, exc::T) where {T<:Union{IncompleteSequenceError,OutputBufferError}}
7562

7663
function iconv_close(cd::Ptr{Nothing})
7764
if cd != C_NULL
78-
ccall((iconv_close_s, libiconv), Cint, (Ptr{Nothing},), cd) == 0 ||
65+
ccall((:libiconv_close, libiconv), Cint, (Ptr{Nothing},), cd) == 0 ||
7966
throw(IConvError("iconv_close"))
8067
end
8168
end
8269

8370
function iconv_open(tocode::String, fromcode::String)
84-
p = ccall((iconv_open_s, libiconv), Ptr{Nothing}, (Cstring, Cstring), tocode, fromcode)
71+
p = ccall((:libiconv_open, libiconv), Ptr{Nothing}, (Cstring, Cstring), tocode, fromcode)
8572
if p != Ptr{Nothing}(-1)
8673
return p
8774
elseif errno() == EINVAL
@@ -144,7 +131,7 @@ function iconv!(cd::Ptr{Nothing}, inbuf::Vector{UInt8}, outbuf::Vector{UInt8},
144131
inbytesleft_orig = inbytesleft[]
145132
outbytesleft[] = BUFSIZE
146133

147-
ret = ccall((iconv_s, libiconv), Csize_t,
134+
ret = ccall((:libiconv, libiconv), Csize_t,
148135
(Ptr{Nothing}, Ptr{Ptr{UInt8}}, Ref{Csize_t}, Ptr{Ptr{UInt8}}, Ref{Csize_t}),
149136
cd, inbufptr, inbytesleft, outbufptr, outbytesleft)
150137

@@ -176,7 +163,7 @@ function iconv_reset!(s::Union{StringEncoder, StringDecoder})
176163

177164
s.outbufptr[] = pointer(s.outbuf)
178165
s.outbytesleft[] = BUFSIZE
179-
ret = ccall((iconv_s, libiconv), Csize_t,
166+
ret = ccall((:libiconv, libiconv), Csize_t,
180167
(Ptr{Nothing}, Ptr{Ptr{UInt8}}, Ref{Csize_t}, Ptr{Ptr{UInt8}}, Ref{Csize_t}),
181168
s.cd, C_NULL, C_NULL, s.outbufptr, s.outbytesleft)
182169

@@ -278,9 +265,6 @@ read from `stream` into text in the encoding `to`. Calling `close` on the
278265
stream does not close `stream`.
279266
280267
`to` and `from` can be specified either as a string or as an `Encoding` object.
281-
282-
Note that some implementations may accept invalid sequences
283-
in the input data without raising an error.
284268
"""
285269
function StringDecoder(stream::IO, from::Encoding, to::Encoding=enc"UTF-8")
286270
cd = iconv_open(String(to), String(from))
@@ -542,7 +526,7 @@ encode(s::AbstractString, enc::AbstractString) = encode(s, Encoding(enc))
542526

543527
function test_encoding(enc::String)
544528
# We assume that an encoding is supported if it's possible to convert from it to UTF-8:
545-
cd = ccall((iconv_open_s, libiconv), Ptr{Nothing}, (Cstring, Cstring), enc, "UTF-8")
529+
cd = ccall((:libiconv_open, libiconv), Ptr{Nothing}, (Cstring, Cstring), enc, "UTF-8")
546530
if cd == Ptr{Nothing}(-1)
547531
return false
548532
else
@@ -555,15 +539,13 @@ end
555539
encodings()
556540
557541
List all encodings supported by `encode`, `decode`, `StringEncoder` and `StringDecoder`
558-
(i.e. by the current iconv implementation).
542+
(i.e. by GNU libiconv).
559543
560544
Note that encodings typically appear several times under different names.
561545
In addition to the encodings returned by this function, the empty string (i.e. `""`)
562546
is equivalent to the encoding of the current locale.
563547
564-
Some implementations may support even more encodings: this can be checked by attempting
565-
a conversion. In theory, it is not guaranteed that all conversions between all pairs of encodings
566-
are possible; but this is the case with all reasonable implementations.
548+
Even more encodings may be supported: this can be checked by attempting a conversion.
567549
"""
568550
function encodings()
569551
filter(test_encoding, encodings_list)

0 commit comments

Comments
 (0)