WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Winsock
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

UrlEncode or iContentUrl cannot handle hebrew characters


Question:

I'm trying to post UrlEncoded Data to a website form.

The website is expecting to recieve the string in Unicode(utf-8) encoding or Windows-1255 encoding.

I partialy succeded by :

  1. writing the string to a text file .
  2. importing the string to a binary buffer.
  3. BinaryConvert the buffer to Unicode.
  4. saving it to a file.
  5. Reading the file.

But i have problem's with the language (Hebrew).

Open the file in NotePad a Copy the string and paste it to the web site , is working but not via the script...

Answer:

Are you specifying the correct code page for BinaryConvert? Probably 1255 for Hebrew. If so, what is the problem that is occuring?

User Reply:

I had solved the problem of the convertion but it seem's that this is not the only one.

while using iHttpOpen() i need to translate the string to UrlEncoded. Either using UrlEncode() of WinSock Extender, or by iContentUrl() of WinInet Extender.in both cases this function do not translate the Hebrew characters right.

Since the UrlEncode() & iContentUrl() can't handle hebrew characters so i decided solving it my self. Here is the code:

;encode the query data to url format
#DefineFunction QueryEncode( QueryString )

Heb="                          "
;UrlHeb ="%D7%90+%D7%91+%D7%92+%D7%93+%D7%94+%D7%95+%D7%96+%D7%97+%D7%98+%D7%99+%D7%9A+%D7%9B+%D7%9C+%D7%9D+%D7%9E+%D7%9F+%D7%A0+%D7%A1+%D7%A2+%D7%A3+%D7%A4+%D7%A5+%D7%A6+%D7%A7+%D7%A8+%D7%A9+%D7%AA"
UrlHeb ="%%D7%%90+%%D7%%91+%%D7%%92+%%D7%%93+%%D7%%94+%%D7%%95+%%D7%%96+%%D7%%97+%%D7%%98+%%D7%%99+%%D7%%9A+%%D7%%9B+%%D7%%9C+%%D7%%9D+%%D7%%9E+%%D7%%9F+%%D7%%A0+%%D7%%A1+%%D7%%A2+%%D7%%A3+%%D7%%A4+%%D7%%A5+%%D7%%A6+%%D7%%A7+%%D7%%A8+%%D7%%A9+%%D7%%AA"


sSize = StrLen( QueryString )

UrlTranslated = ""

HebCount=ItemCount( UrlHeb, "+" )+1

For u=1 to sSize
cChar = StrSub( QueryString, u, 1 ) 
hPos = ItemLocate( cChar, Heb, " " )
If hPos!=0
UrlTranslated=StrCat(UrlTranslated, ItemExtract( HebCount-hPos, UrlHeb, "+" ) )
Else
UrlTranslated=StrCat(UrlTranslated, cChar)
EndIf
Next

Drop( Heb, UrlHeb, sSize, cChar, hPos )

Return UrlTranslated
#EndSubroutine

Article ID:   W15879
File Created: 2017:07:28:12:58:54
Last Updated: 2004:03:30:14:41:20