![]() |
|
|||||||
| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Questions & Help Needed Post any question regarding Basic4ppc. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hello,
i got another one: The code below works fine, but as soon as "mystring" contains Umlauts, an error message complaining about length mismatch occurs. Quote:
Bytes to be written to the stream exceed the Content-Length size specified. stream is a binary file object. Request is a webrequest. Accordingly to the Helpfile, the binaryfile.new1( , false or true) is set to true for ASCII and to false for UTF-8: Quote:
If i set this to true, no error message occurs ( because there's no mismatch between stream length and content-length anymore), but the Umlauts are coverted to something like "?".So ASCII does not help here. regards TWELVE |
|
||||
|
As Agraham wrote you should use the buffer size and not the string size.
You will need to add a Bitwise object: Code:
request.New1(...)
request.Method = "POST"
request.ContentType = "application/x-www-form-urlencoded"
bitwise.New1
s = "Ich fahre nach Österreich"
buffer() = bitwise.StringToBytes(s,0,StrLength(s))
request.ContentLength = ArrayLen(buffer())
stream.New1(request.GetStream,true)
stream.WriteBytes(buffer())
response.New1
response.Value = request.GetResponse
textbox1.Text = response.GetString
|
|
||||
|
Silly me, I used the stream before it was opened
But out of interest do you actually need the Bitwise object? Would this work?Code:
request.New1(...)
request.Method = "POST"
request.ContentType = "application/x-www-form-urlencoded"
s = "Ich fahre nach Österreich"
stream.New1(request.GetStream,false) ' UTF8 encoding
buffer() = stream.StringToBytes(s) ' use the stream to convert
request.ContentLength = ArrayLen(buffer())
stream.WriteBytes(buffer())
response.New1
response.Value = request.GetResponse
textbox1.Text = response.GetString
Why does Erel's example open the stream as ASCII? And does the Bitwise StringToBytes method return UTF8 formatted bytes/characters |
|
||||
|
Quote:
Bitwise.New2 allows you to choose other encodings. Quote:
request.ContentLength must be set before request.GetStream. Otherwise you will get an error. |
|
|||
|
Hello,
i solved this issue now by using: Quote:
Quote:
Quote:
Usually Unicode or UTF-8 is they better choice for supporting different languages / characters.For the moment i will stay with the code page, since this is the quicker fix for me ( the webserver also need an additional module for UTF-8 support..) @Erel: is it possible to implement something like "STRByteLength(string)" to have the bytes of the string counted instead of the characters..? Or maybe as additional parameter in STRLength(string, mode)...? kind regards TWELVE Last edited by TWELVE : 04-28-2008 at 02:40 PM. |
|
||||
|
Quote:
As agraham and I wrote in previous posts you can measure it by first converting the string to bytes (using a specific encoder/code page). |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| HTTP POST error message | miataman | Questions & Help Needed | 10 | 07-11-2008 11:28 AM |
| HTTP POST error | Elrick | Bug Reports | 3 | 05-24-2008 03:06 PM |
| HTTP POST on Device - error message | TWELVE | Questions & Help Needed | 6 | 04-26-2008 10:35 AM |
| HTTP Post | nsidney | Questions & Help Needed | 4 | 01-30-2008 10:52 AM |
| HTTP Post | ohkovar | Questions & Help Needed | 3 | 07-07-2007 05:36 PM |