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

HTTPAPI and I/O utf-8



   Hi Scott,
   I am trying to send a GET request to a google-translate HTML page.
   The HTML-page response is in utf-8 but I would also need to send utf-8
   data to cover any language-pair.
   I tried different things, for Latin character it works but I cannot get
   back or send Japanese for instance.
   I am not sure if this is because I use a GET. I understand that with
   POST you can set the CCSID but I am not sure of what to do for GET.
   Thanks for any tips and in any case thank you for these remarkable
   APIs.
   Pascal
   Here a sample code:
   -----------------------------------------------------------------------
   ---------------------------------
   H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('HTTPAPI')
   ������������������������������������    �   D/copy qrpglesrc,httpapi_h�����������   D/copy qrpglesrc,ifsio_h�������������   ������������������������������������    �   D rc������������� s������������ 10I 0
   D msg������������ s������������ 52A��   D fd������������� s������������ 10I 0
   D toStmf��������� S����������� 256���   ������������������������������������    �   c������������������ eval����� toStmf =
   '/tmp/'��   c�����������������������������������   + 'googleTranslate.html'
   c������������������ callp����   unlink(toStmf)������������������   �/free��������������������������������   ������������������������   �������� fd = open(
   %trimr(toStmf)����������������������������   �������� :
   O_CREAT+O_EXCL+O_RDWR+O_CCSID���������������������   �   ��������   +O_TEXTDATA+O_TEXT_CREAT������������������������    �����   �������� :
   S_IRUSR+S_IWUSR+S_IXUSR+������������������������    ���   ��������   S_IRGRP+S_IWGRP+S_IXGRP+������������������������    �����   ��������   S_IROTH+S_IXGRP����������������������������   ����������   �������� :
   1208����������������������������������    �������������   �������� : 0
   );�����������������������������������    ������������   �/end-free������������������������������   ����������������������   c������������������ eval����� rc =
   http_url_get(�������������������������   c����������������������������   '[1]http://translate.google.com/translate_t?' +
   c*1� ok����������������������   'text=delete&langpair=en|de':��������������   c*2� doesnt work�������������   'text=delete&langpair=en|ja':��������������   c*3 �������������������������   'text='+x'6CF6736368656E'+�����������������   c*3� doesnt work�������������   '&langpair=de|en':�������������������������   c*32�������������������������   'text='+x'006C00F60073006300680065006E'+���   c*32 doesnt work�������������   '&langpair=de|en':�������������������������   c*4 �������������������������   'text='+x'524A9664'+�����������������������   c*4� doesnt work�������������   '&langpair=ja|en':�������������������������   c���������������������������� toStmf)
   c������������������ if������� rc <>
   1���������������   c������������������ eval����� msg =
   http_error������   c������������������   dsply������������������ msg�����   c������������������   endif���������������������������   ������������������������������������    ����������������   c������������������ eval����� *inlr =
   *on�����������   ������������������������������������
   -----------------------------------------------------------------------
   ---------------------------------
   Language� &lang &text��� hex
   English � en �� delete��   German��� de �� löschen� x'6CF6736368656E'
   Japanese� ja ��� �� �� �� x'524A9664'
   On the resulting HTML, the ~translated text~ is just before the string
   '</span></span>' (this string appears only once)

References

   1. http://translate.google.com/translate_t
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------