X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
2908a8f
Implementation of readFileStream and writeFileStream on GRPlatform fo…
May 21, 2020
74b46ba
A bit more succinct implementation of write:toFile:inFolder:
May 23, 2020
7c87436
read/write filestream api implementation on GRPharoPlatform for Pharo7+8
May 23, 2020
05f8180
Merge branch 'mergegrease' into 104/Filestreams
Jul 3, 2020
79512a2
seems like sourcetree took mergegrease branch to merge rather than ma…
Jul 3, 2020
517e32e
Move filestream tests from Pharo-specific tests package to the common…
Jul 3, 2020
c78ddd6
Merge 79512a2068ddab8e320cb2178ce842747214a02e
Jul 3, 2020
5d15eb8
read and write stream methods for GemStone
Jul 3, 2020
831caae
Merge branch 'master' of https://github.com/SeasideSt/Grease into rem…
Jul 3, 2020
9541cd8
added a method to the gemstone core tests package (but needed to monk…
Jul 3, 2020
48a57af
Changed baseline to use separate test package name from GemStome32 on…
Jul 3, 2020
9d4fe1a
Renamed Grease-Tests-GemStone-Core.v32 to Grease-Tests-GemStone32-Cor…
Jul 3, 2020
d7adb2c
missed a rename
Jul 3, 2020
0697d0c
Filestream methods in Squeak
Jul 3, 2020
2289733
remove all the monticello metadata
Jul 3, 2020
6698993
update README to show badge for Pharo9
Jul 12, 2020
4eb931b
update README to show badge for Pharo9 (2)
Jul 12, 2020
1e7daed
Remove comment about dropping `wantsLineEndConversion:`. I don't thin…
Jul 12, 2020
21bf3c4
Merge 4eb931b4a927a55b6863ca8c47f76d0f6004125d
Jul 12, 2020
79ec953
We *can* keep the 'wantsLineEndConversion' when writing out files...
Jul 24, 2020
d321f40
Merge pull request #106 from SeasideSt/104/Filestreams
Jul 24, 2020
625f0ba
Always forgetting to update the grease version...
Jul 31, 2020
ce47230
Fix reading contents of empty binary file
Jul 31, 2020
0168127
Merge pull request #108 from SeasideSt/107-Pharo7-contents-of-empty-b…
Jul 31, 2020
ddcbbaf
cannot believe I keep forgetting to update the version method
Jul 31, 2020
4d8764c
added missing 'codecs' class methods
Nov 14, 2020
81c2f0a
Removed methodProperties.json
Nov 14, 2020
2a326e7
Merge branch 'master' into codecs-gemstone
Nov 14, 2020
ba2be8a
removed monticello metadata
Nov 14, 2020
3eec1fe
Merge branch 'codecs-gemstone' of https://github.com/SeasideSt/Grease…
Nov 14, 2020
2dbfa7b
Merge pull request #112 from SeasideSt/codecs-gemstone
Nov 14, 2020
66c03f6
correct Gemstone 3.5.4 badge
Nov 14, 2020
2457b15
Added GsContext>>namedTempAt: for compatibility and improved GRGemSto…
Dec 20, 2020
03393b6
removed monticello metadata...
Dec 20, 2020
3de3493
More complete test for GRPlatform>>thisContext
Dec 20, 2020
a02d579
added github actions build
Dec 20, 2020
d8f2829
add squeak builds to github action
Dec 20, 2020
4e314bc
Use ZnUTF8Encoder in Pharo9
Dec 26, 2020
7a9d88e
encoded strings in Pharo9 are byte arrays
Dec 26, 2020
64046ba
cross-platform codec tests
Dec 26, 2020
32b50e5
fix more codec tests for cross-platform testing
Dec 26, 2020
59fdaf6
keep the expected failure in earlier pharo
Dec 26, 2020
2bd416b
Keep the old utf8 text converter implementation for those who want to…
Jan 18, 2021
c4823c5
utf8 encoding changes in Pharo9: clean up GRPlatform implementation a…
Jan 19, 2021
5120c51
Fix GRPackage packaging descriptions and tests
Jan 31, 2021
c88f3d2
Set the deprecated utf8 coded as the default for now
Jan 31, 2021
25c6d55
Merge pull request #113 from SeasideSt/thixcontextfix
Jan 31, 2021
9c32aba
Merge pull request #115 from SeasideSt/pharo9-utf8encoding2
Jan 31, 2021
286aff4
Remove pharo4 and 5 from baseline
Jan 31, 2021
da8b40f
dropped pharo4 and 5 from Grease support
Jan 31, 2021
9045692
include pharo9 testing to not allow failures
Jan 31, 2021
4bdebce
updated README
Jan 31, 2021
87b240e
added Gemstone3.6.0 to the line-up
Jan 31, 2021
f46b2a1
set version 1.7.0
Jan 31, 2021
19c9ce6
Gemstone 3.5.4 -> 3.5.5
Jan 31, 2021
d934d66
removing Gemstone 2.4.8 from the line-up on travis-ci
Feb 7, 2021
699f293
added gs3.7 - 3.9 to the baseline
Feb 7, 2021
464fd24
Merge branch 'master' into gsdevkit-merge
Feb 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use ZnUTF8Encoder in Pharo9
  • Loading branch information
Johan Brichau committed Dec 26, 2020
commit 4e314bca481741fa9f7bd96d775e649ac7014740
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
public
nextInt: anInteger

"Answer a random integer in the interval [1, anInteger]"

^ mutex critical: [ generator nextInt: anInteger ]
^ mutex critical: [ generator nextInteger: anInteger ]
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@
decoding
decode: aString
"Convert the given string from UTF-8 using the fast path if converting to Latin-1"
| outStream byte1 byte2 byte3 byte4 unicode stream |
stream := aString readStream.
outStream := WriteStream on: (String new: aString size).
[ stream atEnd not ] whileTrue: [
byte1 := stream next asInteger.
unicode := byte1.
(byte1 bitAnd: 16rE0) = 192 ifTrue: [ "two bytes"
byte2 := stream next asInteger.
(byte2 bitAnd: 16rC0) = 16r80 ifFalse: [ self invalidUtf8 ].
unicode := ((byte1 bitAnd: 31) bitShift: 6) + (byte2 bitAnd: 63) ].
(byte1 bitAnd: 16rF0) = 224 ifTrue: [ "three bytes"
byte2 := stream next asInteger.
(byte2 bitAnd: 16rC0) = 16r80 ifFalse: [ self invalidUtf8 ].
byte3 := stream next asInteger.
(byte3 bitAnd: 16rC0) = 16r80 ifFalse: [ self invalidUtf8 ].
unicode := ((byte1 bitAnd: 15) bitShift: 12) + ((byte2 bitAnd: 63) bitShift: 6)
+ (byte3 bitAnd: 63) ].
(byte1 bitAnd: 16rF8) = 240 ifTrue: [ "four bytes"
byte2 := stream next asInteger.
(byte2 bitAnd: 16rC0) = 16r80 ifFalse: [ self invalidUtf8 ].
byte3 := stream next asInteger.
(byte3 bitAnd: 16rC0) = 16r80 ifFalse: [ self invalidUtf8 ].
byte4 := stream next asInteger.
(byte4 bitAnd: 16rC0) = 16r80 ifFalse: [ self invalidUtf8 ].
unicode := ((byte1 bitAnd: 16r7) bitShift: 18) +
((byte2 bitAnd: 63) bitShift: 12) +
((byte3 bitAnd: 63) bitShift: 6) +
(byte4 bitAnd: 63) ].
unicode ifNil: [ self invalidUtf8 ].
unicode = 16rFEFF "ignore BOM" ifFalse: [
outStream nextPut: (Character codePoint: unicode) ].
unicode := nil ].
^ outStream contents
convenience
decode: aByteArray
^ aByteArray utf8Decoded
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
conversion
decoderFor: aStream
^ GRPharoUtf8CodecStream
^ GRPharoConverterCodecStream
on: aStream
converter: UTF8TextConverter new
converter: ZnCharacterEncoder utf8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
convenience
encode: aString
| writeStream |
writeStream := self encoderFor: (ByteArray new: aString size) writeStream.
writeStream nextPutAll: aString.
^ writeStream contents
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
conversion
encoderFor: aStream
^ GRPharoUtf8CodecStream
^ GRPharoConverterCodecStream
on: aStream
converter: UTF8TextConverter new
converter: ZnUTF8Encoder new
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
streaming
nextPutAll: aString
"Convert the given string from UTF-8 using the fast path if converting to Latin-1"
1 to: aString size by: 1 do: [ :index |
converter nextPut: (aString at: index) toStream: stream ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"commentStamp" : "",
"super" : "GRPharoConverterCodecStream",
"category" : "Grease-Pharo90-Core",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [
"Latin1ToUtf8Encodings",
"Latin1ToUtf8Map"
],
"instvars" : [ ],
"name" : "GRZnUtf8CodecStream",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
running
setUp
| codecStream |
codecStream := ((GRCodec forEncoding: 'utf-8') encoderFor: (WriteStream on: String new)).
codecStream := ((GRCodec forEncoding: 'utf-8') encoderFor: (WriteStream on: ByteArray new)).
countingStream := GRCountingStream on: codecStream
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ testNextPut
countingStream nextPut: (Character codePoint: 16rE4).
self assert: countingStream size = 2.
self assert: countingStream count = 1.
self assert: countingStream contents = (String with: (Character codePoint: 16rC3) with: (Character codePoint: 16rA4))
self assert: countingStream contents = (String with: (Character codePoint: 16rC3) with: (Character codePoint: 16rA4)) asByteArray
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ testNextPutAll
countingStream nextPutAll: (String with: (Character codePoint: 16rE4)).
self assert: countingStream size = 2.
self assert: countingStream count = 1.
self assert: countingStream contents = (String with: (Character codePoint: 16rC3) with: (Character codePoint: 16rA4))
self assert: countingStream contents = (String with: (Character codePoint: 16rC3) with: (Character codePoint: 16rA4)) asByteArray
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
private
asByteArray: aCollectionOfIntegers
^ ByteArray streamContents: [ :stream |
aCollectionOfIntegers do: [ :each |
stream nextPut: each ] ]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ testCodecUtf8
codec := GRCodec forEncoding: codecName.
self assert: codec name asLowercase = codecName asLowercase.
self assert: codec url name asLowercase = codecName asLowercase.
self assert: (codec encode: self decodedString) greaseString = self utf8String greaseString.
self assert: (codec url encode: self decodedString) greaseString = self utf8String greaseString.
self assert: (codec decode: self utf8String) = self decodedString.
self assert: (codec url decode: self utf8String) = self decodedString ]
self assert: (codec encode: self decodedString) asString = self utf8String.
self assert: (codec url encode: self decodedString) asString = self utf8String.
self assert: (codec decode: self utf8ByteArray) = self decodedString.
self assert: (codec url decode: self utf8ByteArray) = self decodedString ]
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ testCodecUtf8Bom
#('UTF-8' 'utf-8') do: [ :codecName |
| codec bom |
codec := GRCodec forEncoding: codecName.
bom := self asString: #(239 187 191).
bom := self asByteArray: #(239 187 191).
self assert: (codec decode: bom , self utf8String) greaseString = self decodedString greaseString.
self assert: (codec url decode: bom , self utf8String) greaseString = self decodedString greaseString ]
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ testCodecUtf8BorderLineString
#('UTF-8' 'utf-8') do: [ :codecName |
| codec writeStream |
codec := GRCodec forEncoding: codecName.
writeStream := codec encoderFor: GRPlatform current readWriteCharacterStream.
writeStream := codec encoderFor: GRPlatform current readWriteByteStream.
writeStream nextPut: (Character codePoint: 0).
writeStream nextPut: (Character codePoint: 255).
writeStream nextPut: (Character codePoint: 256).
self assert: writeStream contents = (String
self assert: writeStream contents asString = (String
with: (Character codePoint: 16r00) "character 0"
with: (Character codePoint: 16rC3) with: (Character codePoint: 16rBF) "character 255"
with: (Character codePoint: 16rC4) with: (Character codePoint: 16r80)) "character 256" ]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ testCodecUtf8ShortestForm
#('UTF-8' 'utf-8') do: [ :codecName |
| codec abc |
codec := GRCodec forEncoding: codecName.
abc := self asString: #(193 129 193 130 193 131 ).
abc := self asByteArray: #(193 129 193 130 193 131 ).
self
should: [ self deny: (codec decode: abc) = 'ABC' ]
raise: Error ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
utf8ByteArray
^ self asByteArray: #(195 156 98 195 168 114 115 116 114 195 174 195 177 103 195 169)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
private
assert: aString next: anInteger startingAt: startIndex gives: anEncodedString
| actual |
actual := String streamContents: [ :stream |
actual := ByteArray streamContents: [ :stream |
((GRCodec forEncoding: 'utf-8') encoderFor: stream)
greaseNext: anInteger putAll: aString startingAt: startIndex ].
self assert: actual = anEncodedString
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ tests
testGreaseNextPutAllStartingAt
| umlaut encodedUmlaut |
umlaut := String with: (Character codePoint: 228).
encodedUmlaut := String with: (Character codePoint: 195) with: (Character codePoint: 164).
self assert: 'ab' next: 1 startingAt: 1 gives: 'a'.
self assert: 'a', umlaut, 'b' next: 1 startingAt: 1 gives: 'a'.
self assert: 'ab', umlaut next: 1 startingAt: 1 gives: 'a'.
self assert: 'a', umlaut, 'b' next: 2 startingAt: 1gives: 'a', encodedUmlaut.
self assert: 'a', umlaut, 'b' next: 1 startingAt: 2 gives: encodedUmlaut.
self assert: 'a', umlaut, 'b' next: 2 startingAt: 2 gives: encodedUmlaut, 'b'.
self assert: 'a', umlaut, umlaut next: 2 startingAt: 2 gives: encodedUmlaut, encodedUmlaut.
self assert: 'ab', umlaut, 'b', umlaut next: 3 startingAt: 2 gives: 'b', encodedUmlaut, 'b'
encodedUmlaut := ByteArray with: (Character codePoint: 195) asInteger with: (Character codePoint: 164) asInteger.
self assert: 'ab' next: 1 startingAt: 1 gives: 'a' asByteArray.
self assert: 'a', umlaut, 'b' next: 1 startingAt: 1 gives: 'a' asByteArray.
self assert: 'ab', umlaut next: 1 startingAt: 1 gives: 'a' asByteArray.
self assert: 'a', umlaut, 'b' next: 2 startingAt: 1 gives: 'a' asByteArray, encodedUmlaut.
self assert: 'a', umlaut, 'b' next: 1 startingAt: 2 gives: encodedUmlaut.
self assert: 'a', umlaut, 'b' next: 2 startingAt: 2 gives: encodedUmlaut, 'b' asByteArray.
self assert: 'a', umlaut, umlaut next: 2 startingAt: 2 gives: encodedUmlaut, encodedUmlaut.
self assert: 'ab', umlaut, 'b', umlaut next: 3 startingAt: 2 gives: 'b' asByteArray, encodedUmlaut, 'b' asByteArray

This file was deleted.

This file was deleted.

X Tutup