[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: httpapi - problem with french special characters
Hi all,
�� I'm Cyril Clemenceau and work with Nicolas Mazo, but he has
better english :-) .
�� Ok, i'll try to explain what we want and we do. As Nicolas
explain you, we want send mail by httpapi through another application.
�� I use Webform to translate special characters in HTTP format, but
i have some trouble.
�� CCSID EBCDIC : 297
�� CCSID ASCII���� : 1208
�� My symplified code :
��� HDATEDIT(*YMD) DATFMT(*ISO)
����� MOD� HALWNULL(*USRCTL)
����� MOD� HOPTION(*NODEBUGIO)
����� /define WEBFORMS
����� /COPY CLEMENCEAU/QCOPSRC,HTTPAPI_H
���� D Form����������� s������������������ like(WEBFORM)
���� D myPointer������ s�������������� *
���� D dataSize������� s������������ 10I 0
���� D w_url���������� S���������� 5000A�� varying
���� D text����������� S������������ 50A�� varying
���� D rc������������� s������������ 10I
0
���� D w_text��������� s���������� 1500A�� varying
���� D pText���������� s�������������� *
����� /free
������ rc = http_SetCCSIDs(1208 : 297);
������ Form = WEBFORM_open� ;
������ WEBFORM_SetVar(Form: 'lib': 'testétest')� ;
������ WEBFORM_SetVar(Form: 'ccr': '75');
������ WEBFORM_SetVar(Form: 'del': %char(0));
������ WEBFORM_SetVar(Form: 'ede':
'[1]destinataire@xxxxxxxxxx')� ;
������ WEBFORM_SetVar(Form: 'eem': '[2]emetteur@xxxxxxxxxx');
������ w_text = 'testétest';
������ pText = %addr(w_text);
������ WEBFORM_setPtr(Form: 'txt': pText:%len(w_text));
������ WEBFORM_postData( Form : myPointer : dataSize )�� ;
������ w_url = '[3]http://myUrlToSendMail/';
������ rc = http_url_post(w_url : myPointer : dataSize :
������������������������������
�� '/tmp/mailAdh.html'
������������������������������� :
HTTP_TIMEOUT
������������������������������� :
HTTP_USERAGENT
������������������������������� :
'text/plain');
������ if� rc <> 1 and rc <> 201;
�������� // on affiche un message d'erreur
�������� text = 'erreur : ' + %char(rc);
�������� dsply text;
������ else;
�������� // on quitte l'écran d'envoi des mails
��������� dsply 'OK';
������ endif� ;
������ WEBFORM_close(Form);
������ *inlr = *on;
������ //
� � � /end-free
My request should contains 'test%C3A9test' in 'lib' and 'txt', but it
contains 'test%C3%A9z%3A%A3'.
When I used 819 in my ASCII CCSID, I obtain 'test%E9test' but '%E9' is
not understand on my web application.
Thank you for you help.
Regards
Cyril
------------------------------
Message: 6
Date: Tue, 25 Jan 2011 22:51:57 +0100
From: Julius Kaj <[4]Kaj.Julius@xxxxxx>
Subject: RE: httpapi - problem with french special characters
To: "'HTTPAPI and FTPAPI Projects'"
<[5]ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
Message-ID:
� � � �<[6]BCC46CE5225EFA45BEC59ED9C7AC5C1E02527E542B63@xxxxxxxxxxxxxxxx
roup.com>
Content-Type: text/plain; charset="iso-8859-1"
Hi Nicolas,
You mention that your problem with the incorrect translation of the
special characters used in the French language surfaced in a
program that is responsible for sending out emails.
I may be wrong, but I'm assuming this means that you're not using
Scott's HTTPAPI in its normal capacity of http client. Most likely
you are using some of the lower level procedures from the library.
That's what I did when I ran into trouble. I was trying to cut a
few corners (or some may say, trying not to reinvent the wheel),
and therefore wanted to use Scott's code to translate some text
before sending it to a streamfile. I looked though the code of
HTTPAPI and when I found the http_xlate procedure, I said to
myself: Ahh, just what I need! (maybe you've done the same?).
Well, it worked - sort of. Just not when I tried to output to CCSID
1208 (UTF-8).
With the help of Scott I was pointed in the right direction:
http_xlatedyn. This procedure uses a scheme of dynamically
allocating extra space for the output if needed. In contrast the
"old" http_xlate procedure simply assumes that the number of
characters will always be the same as the input. That's not always
the case when using UTF-8.
The tricky part in using http_xlate with UTF-8 stems from one af
the even lower level procedures called by it (CCSIDxlate) that
doesn't capture the error code E2BIG returned by iconv (a simple
callp to iconv is used) and therefore the error indication isn't
propagated back to your program and you never get to know that the
conversion actually failed.
I'm not quite sure, why the old http_xlate procedure hasn't been
depricated. I think Scott has explained his reasoning for this in a
post somewhere in the archives. Obviously he has coded his
higher-level functionality in such a way that he can ensure that
the best procedure for the job is chosen. I don't think he
anticipated that people would be using his code in the way I did,
ie. call lower-level procedures directly.
If I'm correct in assuming that your program does use Scott's
low-level procedures, ie. http_xlate or http_xlatep, then you too
will have to change your code to use http_xlatedyn in stead of
http_xlate. In fact http_xlatedyn will always return the correct
translated string, whatever CCSID you're converting from/to. It's
perfectly safe to always use this procedure. It may allocate a
little more memory than strictly needed, though. When the
originally allocated buffer isn't enough, it allocates an
additional 64 Kbytes chunk until the conversion goes through
without failing with the E2BIG error code.
But as others have already told you, until you tell us a little
more about what you're doing in your program, it's a little hard to
guess what help you need.
Best of luck!
Regards,
Kaj
References
1. mailto:destinataire@xxxxxxxxxx
2. mailto:emetteur@xxxxxxxxxx
3. http://myurltosendmail/
4. mailto:Kaj.Julius@xxxxxx
5. mailto:ftpapi@xxxxxxxxxxxxxxxxxxxxxx
6. mailto:BCC46CE5225EFA45BEC59ED9C7AC5C1E02527E542B63@xxxxxxxxxxxxxxxxxxxxxxxx
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------