Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Converting WinHttpRequest response to application code page
Message
From
09/02/2023 04:56:38
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Converting WinHttpRequest response to application code page
Miscellaneous
Thread ID:
01686154
Message ID:
01686154
Views:
63
WinHttpRequest is used to import bank statement from Nordiget.com containing characters from Windows-1257 code page. For unknown reason, FoxPro does replaces accented chartacters with ? signs. To fix this, COMPROP(WinHttpReq ,"UTF8",1) is added:
      WinHttpReq = CREATEOBJECT("WinHttp.WinHttpRequest.5.1")
      WinHttpReq.Open("GET", "https://ob.nordigen.com/api/v2/accounts/11111-22222-333333-4444-/transactions/", .f.)
      WinHttpReq.setrequestheader('accept', 'application/json')
      WinHttpReq.setrequestheader('Authorization', "Bearer afde554a5sd45a45as4")
      WinHttpReq.Send()
      * If this is removed, acented characters appear as single ? signs:
      COMPROP(WinHttpReq ,"UTF8",1)
Response WinHttpReq.ResponseText contains accented characters represented by 4 bytes. First 3 are same but fourth is different. Those characters are converted by code using
    Function NordigetConvert(cStr)
    cstr = strt( cStr, CHR(0xc3)+CHR(0x83)+ CHR(0xc2)+CHR(0x9c) , 'Ü' ) 
    cstr = strt( cStr, CHR(0xc3)+CHR(0x83)+ CHR(0xc2)+CHR(0xBC) , 'ü' ) 
    cstr = strt( cStr, CHR(0xc3)+CHR(0x83)+ CHR(0xc2)+CHR(0x84) , 'Ä' ) 
    cstr = strt( cStr, CHR(0xc3)+CHR(0x83)+ CHR(0xc2)+CHR(0xB6) , 'ö' ) 
    return cStr
This converts only ÜüÄö. There are much more characters to convert.
How to force FoxPro to perform this conversion automatically?
Or can some FoxPro strconv() or other function or WinAPI call used to preform this conversion?

Posted also in https://stackoverflow.com/questions/75396853/how-to-import-unicode-data-from-winhttpreq
Andrus
Next
Reply
Map
View

Click here to load this message in the networking platform