added some partial utf8 related primitives
This commit is contained in:
@ -298,6 +298,25 @@ class(#character,#final,#limited,#immutable) Symbol(String)
|
||||
class(#byte) ByteArray(Array)
|
||||
{
|
||||
## TODO: is it ok for ByteArray to inherit from Array?
|
||||
|
||||
method decodeToCharacter
|
||||
{
|
||||
## TODO: support other encodings. it only supports utf8 as of now.
|
||||
<primitive: #_utf8_to_uc>
|
||||
self primitiveFailed(thisContext method).
|
||||
|
||||
(*
|
||||
### TODO: implement this in moo also..
|
||||
| firstByte |
|
||||
firstByte := self at: 0.
|
||||
if ((firstByte bitAnd:2r10000000) == 0) { 1 }
|
||||
elsif (firstByte bitAnd:2r11000000) == 2r10000000) { 2 }
|
||||
elsif (firstByte bitAnd:2r11100000) == 2r11000000) { 3 }
|
||||
elsif (firstByte bitAnd:2r11110000) == 2r11100000) { 4 }
|
||||
elsif (firstByte bitAnd:2r11111000) == 2r11110000) { 5 }
|
||||
elsif (firstByte bitAnd:2r11111100) == 2r11111000) { 6 }.
|
||||
*)
|
||||
}
|
||||
}
|
||||
|
||||
## -------------------------------------------------------------------------------
|
||||
|
@ -149,7 +149,7 @@ class FcgiSocket(SyncSocket)
|
||||
|
||||
method _run_service
|
||||
{
|
||||
| buf k i |
|
||||
| buf k i hdr |
|
||||
|
||||
self timeout: 10.
|
||||
(*while (true)
|
||||
@ -161,10 +161,12 @@ class FcgiSocket(SyncSocket)
|
||||
buf := ByteArray new: 128.
|
||||
'IM RUNNING SERVICE...............' dump.
|
||||
|
||||
(***self.bs next dump.
|
||||
self.bs next dump.
|
||||
self.bs next dump.***)
|
||||
|
||||
hdr := ByteArray new: 8.
|
||||
k := self.bs next: 8 into: hdr startingAt: 0.
|
||||
|
||||
|
||||
(*
|
||||
i := 0.
|
||||
while (i < 3)
|
||||
{
|
||||
@ -173,9 +175,12 @@ class FcgiSocket(SyncSocket)
|
||||
(buf copyFrom: 10 count: k) dump.
|
||||
i := i + 1.
|
||||
|
||||
(buf copyFrom: 10 count: k) decodeToCharacter dump.
|
||||
|
||||
self.bs nextPut: k from: buf startingAt: 10.
|
||||
}.
|
||||
self.bs flush.
|
||||
*)
|
||||
|
||||
self close.
|
||||
}
|
||||
|
@ -368,8 +368,22 @@ class ByteStream(ByteStreamAdapter)
|
||||
}
|
||||
}
|
||||
|
||||
(*
|
||||
class TextStream(ByteStream)
|
||||
{
|
||||
method initialize
|
||||
{
|
||||
super initialize.
|
||||
self.
|
||||
}
|
||||
|
||||
}
|
||||
method next
|
||||
{
|
||||
}
|
||||
|
||||
method __utf8_to_uc
|
||||
{
|
||||
if (self.seq at: 0) bitAnd:
|
||||
}
|
||||
}*)
|
||||
|
||||
|
@ -42,6 +42,7 @@ class MyObject(Object)
|
||||
'divide by zero'
|
||||
'I/O error'
|
||||
'encoding conversion error'
|
||||
'insufficient data for encoding conversion'
|
||||
'buffer full'
|
||||
).
|
||||
|
||||
|
Reference in New Issue
Block a user