Garbled Display of Parameter Values after Integration

  • Last update:May 08, 2025
  • Overview

    Problem

    After the report is integrated into a web page, you can pass parameters to the report. However, sometimes certain parameter values appear incorrectly as question marks (???), garbled characters, or other unreadable symbols during the passing.  

    Cause

    Due to the difference in encoding between the browser and the report server, errors in multiple encoding conversions of characters lead to the garbled display of characters, which is more likely to occur in Chinese, Japanese, Korean, and special characters.

    Implementation Method

    You can use JavaScript to encode the URL before sending the request to the report server, and then submit it to the server. In this way, completely different encoding results due to different operating systems, different browsers, and different web character sets can be avoided. 

    The consistent output of JavaScript ensures that the server receives uniformly formatted data. 

    You can encode the Chinese characters in the URL, including the template name, parameter name, and parameter value by encodeURIComponent or encodeURI.

     

    Method 

    Non-coded

     Characters

      Application 

    Scenario 

    Example
    encodeURIASCII letters, numbers, ~!@#$&*()=:/,;?+' You can use encodeURI when you need to encode the entire URL and use that URL.encodeURI("http://localhost:8075/webroot/decision/view/report?viewlet=Chinese.cpt")
    encodeURIComponentASCII letters, numbers, ~!*()' You can use encodeURIComponent when you need to encode parameters in a URL.

    "http://localhost:8075/webroot/decision/view/report?viewlet="+encodeURIComponent("Chinese.cpt")

    iconNote: 
    If the URL parameter contains +, it needs to be encoded twice, e.g. encodeURlComponent(encodeURlComponent('+1')).


    So encodeURIComponent has a larger encoding scope than encodeURI. In the actual scenario, you can use encodeURIComponent instead of encodeURI to encode http:// as http%3A%2F%2F. 

    Example

    Encoding Chinese in URLs

    You can use encodeURL to encode the entire URL, as shown in the following: 

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <script Language="JavaScript">             

    function frOpen() {   

    window.location=encodeURI("http://localhost:8075/webroot/decision/view/report?viewlet=GettingStarted.cpt&Region = East China")

     }       

    </script>

    </head>

    <body>

    <input type="button" value="character conversion1" onclick="frOpen()">

    </body>

    </html>

    You can use encodeURIComponent to encode the parameters only:

    window.location="http://localhost:8075/webroot/decision/view/report?viewlet="+encodeURIComponent("Chinese.cpt")

    Encoding Chinese in Form Forms

    You can use encodeURIComponent for encoding conversion before submitting the parameters to the report as a Form form, as shown in the following:

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

    <script>

    function autoSubmit() {

    var Region1 = document.getElementById('Region');//To obtain the text box where the parameter Region is located.

    Region1.value = encodeURIComponent(Region.value);//To convert the parameter value by encoding.

    Region1.name = encodeURIComponent("Region");//To convert the widget name (except English) of the parameter by encoding.

    document.FRform.submit();

    }

    </script>

    <body>

    <form name=FRform method=post action="http://localhost:8075/webroot/decision/view/report?viewlet=doc/Primary/Parameter/Parameter.cpt">

    <input type="text" id="Region" name="Region" value="East China">

    <input type="button" name="show" value= "view" onclick="autoSubmit()"/>

    </body>

    </html>

    Encoding Special Symbols

    You can use encodeURIComponent to encode special symbols such as %, #, $, =, /, ?, and @ included in the parameters in the URI to be encoded.

    iconNote:
    If the URL parameter contains +, it needs to be encoded twice, e.g. encodeURlComponent(encodeURlComponent('+1')).

    You can use the following codes to encode the symbol %China%.

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <script Language="JavaScript">             

    function frOpen() {   

    window.location="http://localhost:8075/webroot/decision/view/report?viewlet=GettingStarted.cpt&"+encodeURIComponent("Region")+"="+encodeURIComponent("%China%")

     }       

    </script>

    </head>

    <body>

    <input type="button" value="character conversion1" onclick="frOpen()">

    </body>

    </html>

    Attachment List


    Theme: Deployment and Integration
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy