.
> Hmmm, it is still not working. I have two forms. One is only text fields
> (multipart false) and one is text fields and input type="file"
> (multipart true). I store the values in the database using Glorp.
> I have two modifications to convert strings. One to utf8 when storing
> in the database and one to convert from utf8 when reading from the
> database.
>> The multipart=false case leads to a proper store of the string in the
> database. The multipart=true does not. Using WAKomEncoded39 the none
> multipart case is displayed correctly. With WAKom the multipart case
> is displayed correct.
>> Examine the kom requests I can see that on multipart=false the strings
> are displaying correct in the inspector. With multipart=true the
> strings are looking strange (no conversion to the squeak encoding???)
>> I don't know much about the multipart stuff. Are the single parts from
> a multipart recognizable of which type they are (binary or text). I
> would like to do a conversion if it is text. Do you have any hint where
> in WAKom this encoding should occurr.
>Ok, now I tested my theory. I added some code to WAKom to convert
multipart fields to an internal representation.
processMultipartFields: aRequest
aRequest multipartFormFieldsDo:
[:chunk |
chunk explore.
chunk fileName isEmptyOrNil ifFalse:
[|stream file|
stream := WriteStream on: String new.
chunk saveToStream: stream.
file := WAFile new
fileName: chunk fileName;
contents: stream contents;
contentType: chunk contentType;
yourself.
aRequest postFields at: chunk fieldName put: file]
ifTrue: [
|stream|
stream := WriteStream on: String new.
chunk saveToStream: stream.
aRequest postFields at: chunk fieldName put:( (stream contents)
convertFromEncoding: #utf8)]
].
That works for me now. It is slower than any other approach while
doing:
- getting UTF-8 from the client (is that always true or how does WAKom
decide?)
- converting multipart and none multipart fields from utf-8 to squeak
- converting the string to utf-8 when storing in the database of the
PostgresQL client encoding utf-8
....
- converting from utf-8 when reading from the database
- Using WAKomEncoded39 which encodes to utf-8 before sending to the
client.
It is much encoding but relatively clean (I think). I can use Umlauts
in squeak code (being squeak encoding).
Does anybody have any doubt about this approach?
Norbert