Reputation: 317
I'm using a web service for passing information from a bunch of old .asp pages to a database. Problem is that using httpGet, I need to encode the info so it can be safely passed.
Everything works like a dream, save for the fact that scandinavian letters such as ä ö and å for example come out as squares. Now I don't even know whether this has to do with the company IIS language settings (can't touch them) or something, but I'm wondering if there's a way to force the asp-page to use a specific encoding, and then force the asp.net web service to decode with the same character-set, without any kind of server settings inbetween getting the chance to mix it all up?
I tried to look around, but didn't find any clear-cut examples of exactly how you can do this. Please keep the replies simple, I'm just a beginner on internship here. Thanks for the help!
Edit: Apologies. Didn't include the code because it was so simple I didn't think it'd reveal anything anyway. Here:
.asp
function loginfo()
Dim text
text = "ääböö"
text = Server.URLENCODE(text)
message = "http://server1/logger_webservice/service.asmx/test_Event?" & _
"userID=" & userID
Set objRequest = Server.createobject("MSXML2.XMLHTTP")
With objRequest
.open "GET", message, False
.setRequestHeader "Content-Type", "text/xml"
.send
End With
loginfo = objRequest.responseText
end function
web server:
<WebMethod()> _
Public Function test_Event(ByVal userId As String) As Boolean
Dim kirj As StreamWriter
kirj = File.CreateText("C:\Inetpub\server1\Logger_WebService\test_logEvent.txt")
userId = Server.UrlDecode(userId)
kirj.WriteLine("userId = " & userId)
kirj.Close()
kirj.Dispose()
End Function
Anyway, thanks for help. I'll be looking into this more but as usual, stress and rush is forcing me to move on. I wrote a simple code to encrypt the most used scandinavian letters manually, and decrypted them in the web server. Works fine so far, I just hope there aren't any complications alter on. Just wanted the basic Finnish letters ä, ö and å anyway. :)
I just thought there was some easy method to force the encoding to a specific charset that I just couldn't find. Tend to be terrible at finding information on my own.
Upvotes: 2
Views: 2138
Reputation: 4410
This recent question that I asked sheds further light on this type of issue with UrlEncoding:
/questions/696659/why-is-this-appearing-in-my-c-strings-194163
It may prove useful to yourself or others hitting this problem.
Upvotes: 1
Reputation: 17010
Without digging into the code, I cannot give you a "here it is on line X" answer, but the issue you are dealing with is one of encoding. There are multiple ways of encoding strings, from ASCII to UTF-8 to full blown Unicode. What this means is Ifforcing full unicode encoding might solve your problem.
To do this, you can explicitly create your streams (and/or readers/writers) with an encoding. The method is different for different types of objects, and not knowing your code, I cannot give you an explicit answer.
With ASP, you may still be getting garbage, however. And, it has been so long since I played with classic ASP, I would have to dig to get an answer there. Fortunately, it sounds like you have a way to test the ASP to ensure the correct characters are coming through, so test. If it works, focus on the web service.
Upvotes: 0