in Search
 
Home Blogs Forums Marketplace Files
 
 
 

Rightfax 9.3 doesnt support Chinese Characters when send fax as HTML

Last post 09-04-2008, 2:06 AM by faxer. 5 replies.
Sort Posts: Previous Next
  •  08-27-2008, 6:50 PM 14167

    Rightfax 9.3 doesnt support Chinese Characters when send fax as HTML

    I am using the Rightfax 9.3 Java API.

    The default languages on my client and servers are English, but i did install Chinese lanuages on these 2 boxes.

    Chinese characters are in UTF8 format, i inserted them into a html string, and use the Java API to send fax as HTML.

    What i receive is '??????????'.

     

    Could anyone help me to answer my questions?

     

  •  08-29-2008, 2:19 AM 14174 in reply to 14167

    Re: Rightfax 9.3 doesnt support Chinese Characters when send fax as HTML

    Are you using InputStreamReader and OutputStreamWriter?

     

  •  08-29-2008, 6:39 AM 14175 in reply to 14174

    Re: Rightfax 9.3 doesnt support Chinese Characters when send fax as HTML

    Hi,

    1. Env in Client:

    Java Version: JDK 1.5

    The Rightfax Version: 9.3

    2. When sending out the fax as attachment, the chinese characters can come out correctly.

        When putting the chinese characters into the html String, Chinese characters become '????' in the fax received.

    3. The Chinese characters are Encoded as 'UTF-8'.

    The Chinese character are retrieved from another system, and they are sent in UTF-8 format.

    If i use the following method to save it as a txt and send the txt file as attachment, the chinese characters can come out.

    Here is the code snippet i used to save the txt file:

    OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("C:/test.txt"),"UTF8");

    4. Actually i want to send fax as html, because i need to generate the fax with dynamic data, and very complicated format. attchment can not satisfy my client's requirements.

    5. Here is the code i am using to send fax.

    public class Test {
    public static void main(String[] args) {
     Test test = new Test();
     test.testBodyInHtml();
    }

     public void testBodyInHtml () {
    // Create a outbound fax object
     RFaxSubmit obFS = new RFaxSubmit();

    // Set the URL of the RightFAX server
     /***************************
      * SG UAT
      * **************************
      */
     obFS.setTargetURL("http://192.168.1.1/");
    // Set the information on who is sending the fax
     obFS.m_FaxDocument.setSenderInfo("IVRTW"); 

    // Add a recipient
     try {
      obFS.m_FaxDocument.addRecipient ("", "67858967", "", "Kiesel fx", "", "", "", "", "", "", "", "");
      
     System.out.println("Added recipient");
     }
     catch (Exception nfne) {
     System.out.println (nfne.toString());
     }

    // Set the body text
     try{
      
      String body = readInput("C:/test.txt"); //readInput() is used to read the txt file, and the read out string is encoded as UTF-8
      //This is used to send fax as html STRING
         obFS.m_FaxDocument.setBody("<![CDATA[" +"<html><body>" + body + "</body></html>"+ "]]>", "HTML") ; // The "test.txt" is the file that contains traditional chinese
        
         //This is used to send fax as attachment
      obFS.addAttachment("c:\\test.txt");
     } catch(java.lang.IllegalArgumentException e){
      e.printStackTrace();
     }

     Vector obRetList = null;
     try {
    // submit xml
     obFS.setDebug(true);
     obRetList = obFS.submit();

    // write out result
     int nSize = obRetList.size();
     for (int i = 0; i < nSize; i++)
     {
     RFStatus obStat = (RFStatus)(obRetList.get(i));
     System.out.println ((i+1) + "-");
     System.out.println ("\tID: " + obStat.getID());
     System.out.println ("\tStatusCode: " + obStat.getStatusCode());
     System.out.println ("\tStatusMessage: " + obStat.getStatusMsg());
     }
     }
     catch (Exception ex) {
     System.out.println ("Error:" + ex.toString());
     }
    }
     /**
      * This method is used to read the txt file in UTF-8.
      * @param strInFile
      * @return
      */
     private static String readInput(String strInFile) {
      StringBuffer buffer = new StringBuffer();
      try {
       FileInputStream fis = new FileInputStream(strInFile);
       InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
       Reader in = new BufferedReader(isr);
       int ch;
       while ((ch = in.read())>-1) {
    //    iCharNum +=1;
        buffer.append((char)ch);
       }
       in.close();
       return buffer.toString();
      } catch (IOException e) {
       e.printStackTrace();
       return null;
      }
     }
    }

     

    After sending the fax, i can receive 2 faxes. The attachement is displayed correctly, and the html string was displayed as all '????'.

     6. The xml generated by the 'Rightfax.zip' Java API doesnt contain Encoding.

    I use "obFS.setDebug(true)" to enable the logs, and find the my fax in sent out to Rightfax server in an xml String. The xml looks like:

    <?xml version="1.0" ?>

    ...

     

    I think if the xml is like

    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

    Then the chinese characters might be decoded correctly. Anyway, that's just my suspicion.

     

    Could you please help me to answer:

    a. What is the root cause that my chinese characters cannot be displayed correctly.

    b. How can i use the API to send Chinese HTML character.

    c. Any work around that i could choose, if i could not send chinese in HTML.

     

    Your help is really important to me.

    Thank you very much.

     

  •  09-01-2008, 2:32 AM 14179 in reply to 14175

    Re: Rightfax 9.3 doesnt support Chinese Characters when send fax as HTML

     

    You are using JDK1.5? JDK 2 provides more extensive support for internationalization

     

    The line m_FaxDocument.setBody("<![CDATA[" +"<html><body>" + body + "</body></html>"+ "]]>", "HTML") doesn't specify the encoding type, which implicitly uses UTF-16 BE. So it can possibly produce data with different encoding, which can make CDATA within the xml to garbage.

     

    Are you running directly off the RightFax server? What Chinese language pack is installed on the RightFax server, Big5 or GB2312,

  •  09-02-2008, 3:47 AM 14181 in reply to 14179

    Re: Rightfax 9.3 doesnt support Chinese Characters when send fax as HTML

    Hi,  Thank you very much for your support.

    1.I am using JDK1.5.  This is a shared env, and JDK version change will not be allowed.

    2. I did test with a encoding in the html,

    Here is the code snippet:  

           info.append("<html><body>");
           info.append("<page contentType='text/html; charset=uft-8'>");
           info.append(readInput("C:/test.txt"));
           info.append("</body></html>");

           m_FaxDocument.setBody("<![CDATA[" +"<html><body>" + info.toString()+ "</body></html>"+ "]]>", "HTML")

    What i received was all question marks, '??????'.

    3. We have installed the Chinese package on Rightfax server for both Big5 and GB2312, but the default language on the server is still English.


    The problem now is that, according to the requirements, user wants a logo displaying on each page, but it seems we can not add a logo to a txt file. Html String is the best way we can choose, plus, it works fine if the language is English. So i really hope you can advise on how can I send the fax as HTML String via API.

     

  •  09-04-2008, 2:06 AM 14191 in reply to 14181

    Re: Rightfax 9.3 doesnt support Chinese Characters when send fax as HTML

    You are limiting yourself to 1.5, then of course you have to be prepared to accept all these errors

    Did you try using BOM for UTF-8, by adding 0xEF 0xBB 0xBF to the front of the stream.

View as RSS news feed in XML
  Privacy    Site Terms   Contact Administrator