Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation of utf32 incorrectly states that an Array of UInt32 is not copied by UTF32String #11389

Closed
ScottPJones opened this issue May 21, 2015 · 2 comments

Comments

@ScottPJones
Copy link
Contributor

While it is true that an Array of Char is not copied, the same as an Array of UInt8 for UTF8String, or of UInt16 for UTF16String, UTF32String copies the array, if it is an Array of UInt32.
Either the documentation should point out this inconsistency, or else the code needs to change to have a constructor that does a reinterpret(Char, array) so as not to copy (which is my vote).
Either way, the documentation should be changed (to say that Array of UInt32 is copied, and Char not, or with the code changed, that both are not copied...)
See https://groups.google.com/forum/#!topic/julia-dev/ZBSelpTlw58

@ScottPJones ScottPJones changed the title Documentation of utf32 incorrectly states that an Array of UInt32 is not copied by UTF32String Documentation of utf32 incorrectly states that an Array of UInt32 is not copied by UTF32String May 21, 2015
@stevengj
Copy link
Member

We should just add the missing constructor that does not do the copy:

UTF32String(data::Vector{UInt32}) = UTF32String(reinterpret(Char, data))

(The convert functions should continue to make a copy.)

@ScottPJones
Copy link
Contributor Author

That's what I had thought... but I am thinking that this is rather dangerous... you basically have mutable strings, whether you like it or not... It might be nicer if there were some way of having an "unsafe" constructor, that could be used by the internals (or where people felt sure they knew what they are doing). For now I'll just add the missing constructor.

ScottPJones added a commit to ScottPJones/julia that referenced this issue May 21, 2015
stevengj added a commit that referenced this issue May 22, 2015
Fix #11389 Add UTF32String constructor for Vector{UInt32}
mbauman pushed a commit to mbauman/julia that referenced this issue Jun 6, 2015
tkelman pushed a commit to tkelman/julia that referenced this issue Jun 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants