Git Product home page Git Product logo

legacystrings.jl's Introduction

LegacyStrings

CI

The LegacyStrings package provides compatibility string types from Julia 0.5 (and earlier), which were removed in subsequent versions, including:

  • ASCIIString: a single-byte-per character string type that can only hold ASCII string data.
  • UTF8String: a string type with single byte code units (UInt8), encoding strings as UTF-8.
  • UTF16String: a string type with two-byte native-endian code units (UInt16), encoding strings as UTF-16.
  • UTF32String: a string type with four-byte native-endian code units (UInt32), encoding strings as UTF-32.
  • ByteString: a type alias for Union{ASCIIString,UTF8String}, i.e. strings that can be passed to C directly.
  • WString: an alias for UTF16String if Cwchart_t is two bytes (i.e. Windows) or UTF32String otherwise.
  • RepString: a string type for efficient handling of repeated strings.

LegacyStrings also defines and exports converter functions for these types, i.e.:

  • ascii: convert to ASCIIString; 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.
  • utf8: convert to UTF8String.
  • utf16: convert to UTF16String.
  • utf32: convert to UTF32String.
  • wstring: alias for utf16 or utf32 according to what WString is an alias to.

legacystrings.jl's People

Contributors

amilsted avatar ararslan avatar bkamins avatar carlobaldassi avatar carstenbauer avatar juliatagbot avatar martinholters avatar matthias314 avatar nalimilan avatar omus avatar quinnj avatar scls19fr avatar staticfloat avatar stefankarpinski avatar stevengj avatar tkelman avatar yuyichao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

legacystrings.jl's Issues

README

messaging/app/src/main/AndroidManifest.xml

Enable AppVeyor

The StefanKarpinski appveyor account should have few things on it any more, less busy than mine. Or we could make a JuliaArchive org account, either way.

using LegacyString breaks `string(::Char)`

ERROR: MethodError: string(::Char) is ambiguous. Candidates:
  string(a::Union{Char,LegacyStrings.ASCIIString,LegacyStrings.UTF8String}...) at /Users/jameson/.julia/v0.6/LegacyStrings/src/utf8.jl:161
  string(a::Union{Char,String}...) at strings/string.jl:179

Warnings about cannot import

when running on julia 1.0

WARNING: could not import Base.lcfirst into LegacyStrings
WARNING: could not import Base.next into LegacyStrings
WARNING: could not import Base.rsearch into LegacyStrings
WARNING: could not import Base.search into LegacyStrings
WARNING: could not import Base.ucfirst into LegacyStrings

master

KeePassJava2-parent org.linguafranca.pwdb 2.1.1-SNAPSHOT ../pom.xml 4.0.0
<artifactId>KeePassJava2</artifactId>
<name>KeepassJava2 :: All</name>
<description>KDB Database support as well as KDBX 3.1: DOM, JAXB and Simple implementations.</description>

<dependencies>
    <dependency>
        <groupId>org.linguafranca.pwdb</groupId>
        <artifactId>KeePassJava2-kdb</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>org.linguafranca.pwdb</groupId>
        <artifactId>KeePassJava2-dom</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>org.linguafranca.pwdb</groupId>
        <artifactId>KeePassJava2-jaxb</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>org.linguafranca.pwdb</groupId>
        <artifactId>KeePassJava2-simple</artifactId>
        <version>${project.version}</version>
    </dependency>
</dependencies>

Tag new release

After #36 it would be useful to have a new release tagged. This would reduce warnings when precompiling packages that depend on LegacyStrings, like JLD, on 1.0.

Is this possible?

Is it possible to construct a UTF32String from an Array{Char, 1}?

From the error prompt from my REPL I thought it would be possible to construct a UTF32String from Array{Char, 1}. However, when I try to do so, I get

julia> t = "asdf"
"asdf"

julia> c = Vector{Char}(t)
4-element Array{Char,1}:
 'a'
 's'
 'd'
 'f'

julia> UTF32String(c)

ERROR: MethodError: no method matching UTF32String(::Base.ReinterpretArray{UInt32,1,Char,Array{Char,1}})
Closest candidates are:
  UTF32String(::Array{UInt32,1}) at /home/jx/.julia/packages/LegacyStrings/tkVHE/src/LegacyStrings.jl:96
  UTF32String(::Array{Char,1}) at /home/jx/.julia/packages/LegacyStrings/tkVHE/src/utf32.jl:3
Stacktrace:
 [1] UTF32String(::Array{Char,1}) at /home/jx/.julia/packages/LegacyStrings/tkVHE/src/utf32.jl:3
 [2] top-level scope at none:0

which is weird to me since the second candidate literally says UTF32String(::Array{Char,1}).

Is the only way to construct a UTF32String via utf32(s)?

ambiguous three-argument nextind for DirectIndexString

It seems that LegacyStrings is missing a nextind definition:

julia> str = ASCIIString(zeros(10))
"\0\0\0\0\0\0\0\0\0\0"

julia> str = ASCIIString(zeros(1000))
Error showing value of type ASCIIString:
ERROR: MethodError: nextind(::ASCIIString, ::Int64, ::Int64) is ambiguous.

master

KeePassJava2-parent org.linguafranca.pwdb 2.1.1-SNAPSHOT ../pom.xml 4.0.0
<artifactId>KeePassJava2</artifactId>
<name>KeepassJava2 :: All</name>
<description>KDB Database support as well as KDBX 3.1: DOM, JAXB and Simple implementations.</description>

<dependencies>
    <dependency>
        <groupId>org.linguafranca.pwdb</groupId>
        <artifactId>KeePassJava2-kdb</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>org.linguafranca.pwdb</groupId>
        <artifactId>KeePassJava2-dom</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>org.linguafranca.pwdb</groupId>
        <artifactId>KeePassJava2-jaxb</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>org.linguafranca.pwdb</groupId>
        <artifactId>KeePassJava2-simple</artifactId>
        <version>${project.version}</version>
    </dependency>
</dependencies>

readme

``

`hash` performance

julia> a_string="a"^32;

julia> a_asciistring = ASCIIString(a_string);

julia> a_utf8string = UTF8String(a_string);

julia> @btime hash(a_string)
  24.000 ns (1 allocation: 16 bytes)
0xd44c9a12c524b43a

julia> @btime hash(a_asciistring)
  354.739 ns (5 allocations: 240 bytes)
0xd44c9a12c524b43a

julia> @btime hash(a_utf8string)
  460.051 ns (5 allocations: 240 bytes)
0xd44c9a12c524b43a

New release

Would it be possible to create a new release? I just ran into an issue where the Compats requirements in the previous release was preventing other packages from being updated, in particular Optim. Using the latest master solved the issue, but it would be nice to have to rely on that. Thanks!

RepString("",1) throws in show

Moved from JuliaLang/julia#19564

julia> RepString("",1)
"Error showing value of type RepString:
ERROR: BoundsError: attempt to access 0-element Array{UInt8,1} at index [0]
in next(::String, ::Int64) at ./strings/string.jl:88
in next(::String, ::Int64) at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib:?
in escape_string(::IOContext{Base.Terminals.TTYTerminal}, ::RepString, ::String) at ./strings/io.jl:139
in print_quoted at ./strings/io.jl:158 [inlined]
in show at ./strings/io.jl:72 [inlined]
in show at ./replutil.jl:4 [inlined]
in display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::RepString) at ./REPL.jl:132
...

I noticed this when testing out #19548. (Bug appears to be in all Julia versions since at least 0.3.)

Add new options for convert to allow/disallow accepting different input and invalids with replacement strings

Moved from JuliaLang/julia#12358 (comment).

Currently, there is a single convert method that allows conversion to UTF8String with a argument for a replacement string, but that is only defined for an input of Vector{UInt8}, and not from the very many different possible arguments to convert(UTF8String, data).
There are other places in the code where a fixed replacement, 0xfffd, is hard-coded.

  1. There needs to be consistent handling for converting strings from vectors of code units (UInt8, UInt16, and UInt32) to the (current) 4 types of strings ASCIIString,UTF8String,UTF16String,UTF32String, that allows specifying the handling of Modified UTF-8, CESU-8, overly long encodings, and also whether invalid sequences should cause an exception, be replaced by a default replacement character (0xfffd for Unicode, 0x1a [SUB] for ASCII), or replaced by a user supplied string.
  2. This also needs to work with fixes for #11501 and #11502
  3. As laid out in #11558, make sure only valid strings are produced (for security reasons and in the future performance reasons)

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

precompile error

On LegacyStrings 0.3.0 running using LegacyStrings gives me:

INFO: Precompiling module LegacyStrings.
WARNING: Module Compat with uuid 564795069695402 is missing from the cache.
This may mean module Compat does not support precompilation but is imported by a module that does.
ERROR: LoadError: Declaring precompile(false) is not allowed in files that are being precompiled.
Stacktrace:
[1] _require(::Symbol) at .\loading.jl:455
[2] require(::Symbol) at .\loading.jl:405
[3] include_from_node1(::String) at .\loading.jl:576
[4] include(::String) at .\sysimg.jl:14
[5] anonymous at .<missing>:2
while loading C:\Users\Max\AppData\Local\JuliaPro-0.6.2.1\pkgs-0.6.2.1\v0.6\LegacyStrings\src\LegacyStrings.jl, in expression starting on line 46

Julia:

Julia Version 0.6.2
Commit d386e40c17* (2017-12-13 18:08 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, skylake)

Types wrongly redefined in early 0.5.0-dev

I am stuck at a particular version of Julia (0.5.0-dev+2349) where UTF-16 and UTF-32 types are still defined in Base (that's pre PR #16590). This creates problems because LegacyString then redefines these types.

I used the following fix in LegacyStrings.jl, line 45:

+    if !isdefined(Base, :UTF16String)
-    if VERSION >= v"0.5.0-"

I guess this is a fairly rare case but it might be worth relying more on isdefined than on version checks?

PS. I can prepare a pull request if you agree on that kind of change.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.