[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending Big5 through httpapi



Hello,

It's important for you to understand what you are doing, here.  I cannot
do this for you, I do not have access to a Chinese system to test this
with.  You need to understand what the requirements are, please don't
expect me to know.

CCSID 950 may work sufficiently well.  I don't know!

But, if your data in your RPG program is in CCSID 937, and the website
you're interacting with is CCSID 950, then yes, you should code it like
this:

http_setCCSIDs(950:937)

Personally, it surprises me that you'd want the data to be in CCSID 950.
 I would've expected it to be UTF-8, since that's the normal character
set used in all web applications, and UTF-8 supports all languages.  If
the data in your RPG program is in 937, and you want to use UTF-8, then
code:

http_setCCSIDs(1208:937)

But please don't expect _me_ to know what _you_ want to do. Every web
service or web site is different.   I can only tell you what the
standard, normal, default one is... and that's 1208 (UTF-8).  In any
case, HTTPAPI will do what you ask it to... it'll translate it to either
950 or 1208 or whatever you ask it to do.   The only requirement is that
the output be some variant of ASCII since that's what your HTTP server
is going to expect.

Also...  please understand what URL encoding is.  The idea is to set
variables that are passed as part of your URL...  so you may have a site
that takes the following variables with corresponding values:

var1    My name is scott klement
var2    I am a programmer/analyst

These need to be in a URL, which can only contain certain characters.
It can't contain the / character, because that denotes a directory
separator.  It can't contain spaces, because a space denotes the end of
the URL in the HTTP protocol.

Also, since you have more than one variable, there needs to be a way to
separate the variable from it's value, and the value from the next
variable in the URL, so that a program can easily understand what it's
being sent.

And this is the scheme that the founding fathers of the web came up with:

1) A ? character separates the "query string" (the spot where the
variables are) from the pathname in the URL

2) A & character separates each variable from the next.

3) A = character separates each variable from it's value.

4) Any characters that have special meaning in the URL (including the ?,
&, = characters (amongst others), as well as spaces, slashes, or any
character that doesn't fall into the basic letters/numbers of the
US-ASCII character set) need to be encoded with their hex values.

5) Hex values are represented as %xx where xx represent the hex nibbles
of that byte.

Why does HTTPAPI require that you set your variable name to 'msg'
instead of '&msg'?  Because the & isn't part of the variable name...
it's a separator that separates the variable name from the next
variable.  If you tell HTTPAPI that the variable name is '&msg' then it
thinks you want the & to be PART OF the name, rather than a separator,
and so it encodes it with it's hex equivalent.

As to whether it supports Big5 Chinese...    I guess we're about to find
out!   I don't know if anyone's ever tried it before?   But HTTPAPI just
asks OS/400 to translate from one CCSID to another, it doesn't know or
care what the data in the string is.  So provided you give it the
correct CCSIDs, and use the routines as they were intended to be used, I
don't see why it wouldn't work...

On 9/13/2010 11:45 PM, CISD Hang Lam Chan wrote:
> Dear Scott,
> 
> Thanks for your help.
> Before I go to next steps as you suggested, I just want to make it clear what I want and where is the problem.
> 
> [Simply Description]
> PC client (CCSID = 950) running Clinet Access and user input "我" (=x'A7DA') into AS400 running CCSID = 937, and AS400 store the value x'4F5C' in Physical File
> 
> [Objective]
> A program is needed to send the x'4F5C' as stored in Physical File of AS400 to PC server running CCSID = 950 throuhg HTTP protocol as value x'A7DA' received in PC Sever side
> 
> [Problem]
> When this program sent x'4F5C' to PC server, the server received as x'7C2A'
> We find that this mapping follow mapping ISO-8859-1
> 
> The Answering from IBM is for CCSID in this case:
> If I input an character "我" from Client Access with host-code page 937 to a physical file with CCSID 937, provided the Windows locale is Traditional Chinese (you may check by typing command "chcp" to get 950), you will yield 4F5C where you stored in iSeries. It is a correct.
> And note 4F5C is EBCIDIC hex value. For CCSID 937, there is no character for EBCIDIC hex value for B5FE by default except you tailor-made one for it. Please see the screenshots that I captured from ICU site describing IBM-937. (http://demo.icu-project.org/icu-bin/convexp)
> 
> Could you suggest the values used in http_setCCSIDs(remote:local)?
> Ie. http_setCCSIDs(950:937)?
> 
> Regards
> 
> -----------------------------------------------------
> -----Original Message-----
> From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Scott Klement
> Sent: Tuesday, September 14, 2010 12:20 AM
> To: HTTPAPI and FTPAPI Projects
> Subject: Re: Sending Big5 through httpapi
> 
> As I said in the previous message, you have to be running the current
> *beta* version for HTTP_setCCSIDs() to work with the URL encoder.
> You can retrieve the current beta here:
> http://www.scottklement.com/httpapi/beta
> 
> You need to call the URL encoding routines to fill in the data.  To call
> them (remember, you need the *beta* for setCCSIDs to work) you should do
> this:
> 
>    a) Call http_setCCSIDs()
>    b) Call HTTP_url_encoder_new() or webform_open()
>    c) Call HTTP_url_encoder_addvar, http_url_encoder_addvar_s,
>            webform_setPtr, or webform_setvar for each variable
>            you wish to set in the URL
>    d) Call HTTP_url_encoder_getstr() or webform_getdta() to
>            retrieve the encoded data so you can add it to
>            your URI
>    e) Call http_url_encoder_free() or webform_close() to
>            clean up the memory used by the encoder.
> 
> 
> 
> On 9/13/2010 3:58 AM, CISD Hang Lam Chan wrote:
>> Hi,
>>
>> Using&msg=%a7%da' is fine, however, ss the user will input message content, the data will be changed and I cannot hard-coded as&msg=%a7%da';
>>
>> I did try to use http_setCCSIDs() to set the CCSID, but it doesn't work.
>> And, as you said I am not calling the URL encoding routines, could you let me know which routine should I call so that I can use the http_setCCSIDs() correctly?
>>
>> Regards
>>
>> -----Original Message-----
>> From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Scott Klement
>> Sent: Saturday, September 11, 2010 1:52 AM
>> To: HTTPAPI and FTPAPI Projects
>> Subject: Re: Sending Big5 through httpapi
>>
>> Hello,
>>
>>>       I am using version 1.23 and trying to send out data by RPG using
>>>       HTTPAPI from AS400 to a PC with CCSID 950
>>
>> HTTPAPI does not attempt to URL-encode your URI automatically.  It
>> assumes that you are passing a valid URL to it, that's already been
>> encoded accordingly.
>>
>> The HTTP standard does not allow characters that are not part of
>> ISO-8859-1 (CCSID 819) in a URI.  The standards state that the HTTP
>> protocol will always use ISO-8859-1.
>>
>> If you use the current BETA version of HTTPAPI, and you call the URL
>> encoding routines (which you are not currently doing) it'll allow you to
>> set an alternative CCSID via http_setCCSIDs() to use UTF-8 data, and
>> then it'll encode it for you to make it a valid URL.  But since you are
>> not even attempting to call those routines now, HTTPAPI is definitely
>> going to mistranslate your URL.
>>
>> If your data never changes, you could do this:
>>
>>      Eval      URL = 'http://somewhere.com'
>>                     + '/app/servlet/GenSendSM?'
>>                     + 'acc=my_acc'
>>                     + '&pwd=my_pwd'
>>                     + '&msisdn='
>>                     + '&msg=%a7%da';
>>
>> This is (presumably) what the URL encoder would arrive at if you updated
>> and used the URL encoder...
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------