[Cuis] (Minimal) requirements for Unicode support?

H. Hirzel hannes.hirzel at gmail.com
Wed Feb 13 11:46:22 CST 2013


Hello Juan

> On 2/8/13, Juan Vuletich <juan at jvuletich.org> wrote:

>> Unfortunately, this means I broke the examples at
>> https://github.com/hhzl/Cuis-Add-Ons/blob/master/UnicodeNotes.md .

I have updated the file UnicodeNotes.md

and I did a test class (attached) which shows how to read and write an
UTF8 file.

test5ReadWriteUtf8
	
	"see UnicodeNotes.md"
	
     "self new test5ReadWriteUtf8"
     | stream content byteArray byteArray2 |

	"read UTF8 Unicode file into internal string with NCRs"
	"for NCR see http://en.wikipedia.org/wiki/Numeric_character_reference"
	
	stream := (FileStream  fileNamed:  self class fileName) binary.
	byteArray := stream contentsOfEntireFile.
      content := String fromUtf8: byteArray.
	"NCRs were added to 'content' as needed"

	"write internal string back to UTF8 file with NCRs converted back to
UTF8 chars"
	stream := (FileStream  forceNewFileNamed:  self class fileName2) binary.
	stream nextPutAll: (content asUtf8: true).  "true means: convert NCRs
back to UTF8"
	stream close.

      "compare the two versions: what is in file 'fileName' with what
is in file 'fileName2'"
	stream := (FileStream  fileNamed:  self class fileName) binary.
	byteArray := stream contentsOfEntireFile.
	stream close.

	stream := (FileStream  fileNamed:  self class fileName2) binary.
	byteArray2 := stream contentsOfEntireFile.
	stream close.

	self assert: byteArray = byteArray2.


BTW according to http://en.wikipedia.org/wiki/UTF8 'Official name and variants'
UTF8 should all be uppercase.

As of now I can use Cuis 4.1-1590 as is for my work which includes
reading and writing UTF8 encoded text files (including HTML files). So
as far as I am concerned further extended Cuis Unicode support might
be put on the back burner for some time.

However it might still be worthwhile considering maintaining a
TextConverter and UTF8Converter class for compatibility and other
reasons. More on this later.

Thank you for the update

https://github.com/jvuletich/Cuis/blob/master/UpdatesSinceLastRelease/1590-InvertibleUTF8Conversion-JuanVuletich-2013Feb08-08h11m-jmv.1.cs.st

and

kind regards

Hannes Hirzel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: UnicodeTest4dot1dash1590.st
Type: application/octet-stream
Size: 4287 bytes
Desc: not available
URL: <http://jvuletich.org/pipermail/cuis_jvuletich.org/attachments/20130213/27ab151e/attachment-0004.obj>


More information about the Cuis mailing list