Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottPJones committed Jun 11, 2015
1 parent d2afc0f commit 19e853d
Showing 1 changed file with 47 additions and 47 deletions.
94 changes: 47 additions & 47 deletions base/utf32.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ convert(::Type{UTF32String}, c::Char) = UTF32String(Char[c, Char(0)])
convert(::Type{UTF32String}, s::UTF32String) = s

"
Converts an AbstractString to a UTF16String
Converts an `AbstractString` to a `UTF16String`
### Input Arguments:
* ::Type{UTF32String}
* str::AbstractString
* `::Type{UTF32String}`
* `str::AbstractString`
### Returns:
* ::UTF32String
* `::UTF32String`
### Throws:
* UnicodeError
* `UnicodeError`
"
function convert(::Type{UTF32String}, str::AbstractString)
len, flags = check_string(str)
Expand All @@ -38,17 +38,17 @@ function convert(::Type{UTF32String}, str::AbstractString)
end

"
Converts a UTF-32 encoded vector of UInt32 to a UTF8String
Converts a UTF-32 encoded vector of `UInt32` to a `UTF8String`
### Input Arguments:
* ::Type{UTF8String}
* dat::Vector{UInt32}
* `::Type{UTF8String}`
* `dat::Vector{UInt32}`
### Returns:
* ::UTF8String
* `::UTF8String`
### Throws:
* UnicodeError
* `UnicodeError`
"
function convert(::Type{UTF8String}, dat::Vector{UInt32})
len = sizeof(dat)
Expand All @@ -61,17 +61,17 @@ function convert(::Type{UTF8String}, dat::Vector{UInt32})
end

"
Converts a UTF32String to a UTF8String
Converts a `UTF32String` to a `UTF8String`
### Input Arguments:
* ::Type{UTF8String}
* str::UTF32String
* `::Type{UTF8String}`
* `str::UTF32String`
### Returns:
* ::UTF8String
* `::UTF8String`
### Throws:
* UnicodeError
* `UnicodeError`
"
function convert(::Type{UTF8String}, str::UTF32String)
dat = reinterpret(UInt32, str.data)
Expand All @@ -85,17 +85,17 @@ function convert(::Type{UTF8String}, str::UTF32String)
end

"
Converts a UTF8String to a UTF32String
Converts a `UTF8String` to a `UTF32String`
### Input Arguments:
* ::Type{UTF32String}
* str::UTF8String
* `::Type{UTF32String}`
* `str::UTF8String`
### Returns:
* ::UTF32String
* `::UTF32String`
### Throws:
* UnicodeError
* `UnicodeError`
"
function convert(::Type{UTF32String}, str::UTF8String)
dat = str.data
Expand All @@ -104,11 +104,10 @@ function convert(::Type{UTF32String}, str::UTF8String)
# Validate UTF-8 encoding, and get number of words to create
len, flags = check_string(dat)
# Optimize case where no characters > 0x7f
totlen = len+1
flags == 0 && return fast_utf_copy(UTF32String, Char, totlen, dat)
flags == 0 && @inbounds return fast_utf_copy(UTF32String, Char, len, dat, true)
# has multi-byte UTF-8 sequences
buf = Vector{Char}(totlen)
@inbounds buf[totlen] = 0 # NULL termination
buf = Vector{Char}(len+1)
@inbounds buf[len+1] = 0 # NULL termination
local ch::UInt32, surr::UInt32
out = 0
pos = 0
Expand Down Expand Up @@ -142,20 +141,19 @@ function convert(::Type{UTF32String}, str::UTF8String)
end
UTF32String(buf)
end
>>>>>>> 2d23e4d... Fix #10959 UTF-32 conversion errors

"
Converts a UTF16String to UTF32String
Converts a `UTF16String` to `UTF32String`
### Input Arguments:
* ::Type{UTF32String}
* str::UTF16String
* `::Type{UTF32String}`
* `str::UTF16String`
### Returns:
* ::UTF32String
* `::UTF32String`
### Throws:
* UnicodeError
* `UnicodeError`
"
function convert(::Type{UTF32String}, str::UTF16String)
dat = str.data
Expand All @@ -180,17 +178,17 @@ function convert(::Type{UTF32String}, str::UTF16String)
end

"
Converts a UTF-32 encoded vector of UInt32 to a UTF16String
Converts a UTF-32 encoded vector of `UInt32` to a `UTF16String`
### Input Arguments:
* ::Type{UTF16String}
* dat::Vector{UInt32}
* `::Type{UTF16String}`
* `dat::Vector{UInt32}`
### Returns:
* ::UTF16String
* `::UTF16String`
### Throws:
* UnicodeError
* `UnicodeError`
"
function convert(::Type{UTF16String}, dat::Vector{UInt32})
len = sizeof(dat)
Expand All @@ -200,22 +198,22 @@ function convert(::Type{UTF16String}, dat::Vector{UInt32})
len, flags, num4byte = check_string(dat, len>>>2)
len += num4byte + 1
# optimized path, no surrogates
num4byte == 0 && return fast_utf_copy(UTF16String, UInt16, len, dat)
num4byte == 0 && @inbounds return fast_utf_copy(UTF16String, UInt16, len, dat)
return encode_to_utf16(dat, len)
end

"
Converts a UTF32String to UTF16String
Converts a `UTF32String` to `UTF16String`
### Input Arguments:
* ::Type{UTF16String}
* str::UTF32String
* `::Type{UTF16String}`
* `str::UTF32String`
### Returns:
* ::UTF16String
* `::UTF16String`
### Throws:
* UnicodeError
* `UnicodeError`
"
function convert(::Type{UTF16String}, str::UTF32String)
dat = reinterpret(UInt32, str.data)
Expand All @@ -230,14 +228,14 @@ function convert(::Type{UTF16String}, str::UTF32String)
end

"
Converts an already validated UTF-32 encoded vector of UInt32 to a UTF16String
Converts an already validated UTF-32 encoded vector of `UInt32` to a `UTF16String`
### Input Arguments:
* dat::Vector{UInt32} UTF-32 encoded data
* len length of output in 16-bit words
* `dat::Vector{UInt32}` UTF-32 encoded data
* `len` length of output in 16-bit words
### Returns:
* ::UTF16String
* `::UTF16String`
"
function encode_to_utf16(dat, len)
buf = Vector{UInt16}(len)
Expand All @@ -263,10 +261,12 @@ convert(::Type{UTF32String}, c::Char) = UTF32String(Char[c, Char(0)]

function convert(::Type{UTF32String}, str::ASCIIString)
dat = str.data
fast_utf_copy(UTF32String, Char, length(dat)+1, dat)
@inbounds return fast_utf_copy(UTF32String, Char, length(dat), dat, true)
end

convert(::Type{UTF32String}, dat::AbstractVector{Char}) = fast_utf_copy(UTF32String, Char, length(dat), dat, true)
function convert(::Type{UTF32String}, dat::AbstractVector{Char})
@inbounds return fast_utf_copy(UTF32String, Char, length(dat), dat, true)
end

function convert(::Type{UTF32String}, data::AbstractVector{Char})
len = length(data)
Expand Down

0 comments on commit 19e853d

Please sign in to comment.