instance method
ucharenc
Ruby on Rails 2.3.18
Since v2.3.18 Last seen in v3.0.20Available in: v2.3.18 v3.0.20
Signature
ucharenc(a, i, u)
Encodes unicode character u as UTF-8 bytes in string a at position i. Returns the number of bytes written.
Parameters
-
areq -
ireq -
ureq
Source
# File activesupport/lib/active_support/json/backends/okjson.rb, line 342
def ucharenc(a, i, u)
case true
when u <= Uchar1max
a[i] = (u & 0xff).chr
1
when u <= Uchar2max
a[i+0] = (Utag2 | ((u>>6)&0xff)).chr
a[i+1] = (Utagx | (u&Umaskx)).chr
2
when u <= Uchar3max
a[i+0] = (Utag3 | ((u>>12)&0xff)).chr
a[i+1] = (Utagx | ((u>>6)&Umaskx)).chr
a[i+2] = (Utagx | (u&Umaskx)).chr
3
else
a[i+0] = (Utag4 | ((u>>18)&0xff)).chr
a[i+1] = (Utagx | ((u>>12)&Umaskx)).chr
a[i+2] = (Utagx | ((u>>6)&Umaskx)).chr
a[i+3] = (Utagx | (u&Umaskx)).chr
4
end
end
Defined in activesupport/lib/active_support/json/backends/okjson.rb line 342
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::OkJson