Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0007603 [Squeak] XML-Yaxo major always 01-30-11 01:00 02-06-11 23:47
Reporter unoduetre View Status public  
Assigned To leves
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version trunk Product Version 4.1
  Product Build
Summary 0007603: XMLWriter and MultiByteFileStream
Description XMLWriter in #writeXmlEncoded:
uses #next:putAll:startingAt:
but MultiByteFileStream doesn't implement it.
Instead it's implemented in StandardFileStream, but there it uses
#primWrite:from:startingAt:
So!
If XMLWriter tried to write some WideString with some national characters part of the output file is written in UTF-8, and part is written in strange way using
null bytes etc. (it uses four bytes for one character, i suppose it's internal coding of squeak).

To reproduce try:
file:=FileStream fileNamed:'test.txt'.
xml:=XMLString string: 'abc
def' asWideString.
xml printOn: file

output file is (in hex): 61 0 0 0 62 0 0 0 63 0 0 0

On the other hand the following code works correctly:
file:=FileStream fileNamed:'test.txt'.
xml:=XMLString string: 'abcdef' asWideString.
xml printOn: file
Steps To Reproduce
Additional Information
Attached Files

- Relationships

- Notes
(0014035 - 1022 - 2819 - 2819 - 2819 - 2819 - 2819)
unoduetre
01-30-11 02:23

fast patch (not the best one...)

writeXmlEncoded: aString
    | lastIndex nextIndex |
    
    "Unroll the first search"
    lastIndex := 1.
    nextIndex := String
        findFirstInString: aString
        inSet: SpecialCharacters byteArrayMap
        startingAt: lastIndex.
    nextIndex isZero
        ifTrue: [^ self nextPutAll: aString].

    [nextIndex isZero]
        whileFalse: [| nextChar |
            stream
                "next: nextIndex - lastIndex putAll: aString startingAt: lastIndex;"
                nextPutAll: (aString copyFrom: lastIndex to: nextIndex - 1);
                nextPutAll:
                    (((nextChar := aString at: nextIndex) == LineFeed or: [nextChar == CarriageReturn])
                        ifTrue: [self lineBreak]
                        ifFalse: [CharacterEscapes at: nextChar]).
            lastIndex := nextIndex + 1.
            nextIndex := String
                findFirstInString: aString
                inSet: SpecialCharacters byteArrayMap
                startingAt: lastIndex].

    "stream next: aString size - lastIndex + 1 putAll: aString startingAt: lastIndex."
    stream nextPutAll: (aString copyFrom: lastIndex to: aString size).
 
(0014038 - 246 - 246 - 246 - 246 - 246 - 246)
leves
01-31-11 02:01

Though I couldn't reproduce the bug with the given example, because there's no XMLString class in Squeak or the XML-Writer package, the issue related to Squeak is fixed in Multilingual-ul.135. The corresponding test is in MultilingualTests-ul.14.
 
(0014039 - 163 - 169 - 297 - 297 - 297 - 297)
unoduetre
01-31-11 02:22

Ok. XMLString is in another package afair (also on squeaksource, http://www.squeaksource.com/XMLSupport) [^]
But if it's solved it doesn't matter anymore. Thanks. :-D
 

- Issue History
Date Modified Username Field Change
01-30-11 01:00 unoduetre New Issue
01-30-11 02:23 unoduetre Note Added: 0014035
01-31-11 02:01 leves Status new => resolved
01-31-11 02:01 leves Fixed in Version  => trunk
01-31-11 02:01 leves Resolution open => fixed
01-31-11 02:01 leves Assigned To  => leves
01-31-11 02:01 leves Note Added: 0014038
01-31-11 02:22 unoduetre Note Added: 0014039
02-06-11 23:47 leves Status resolved => closed


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
45 total queries executed.
35 unique queries executed.
Powered by Mantis Bugtracker