18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

how to deal with filename like GB2312 Windows-31J etc

beesmanbeesman Members
edited August 2010 in Sahi - Open Source
hi

when the script file name like
香港.sah
画面.sah

the script file name can't display properly in playback tab file field

ControllerUI.java
    public HttpResponse scriptsListJSON(final HttpRequest request) {
        String dir = request.getParameter("dir");
        String[] fileList = ScriptUtil.getScriptFiles(dir);
//here is properly output in sahi console
        System.out.println("scriptsListJSON():" + Utils.toJSON(fileList));
        return new NoCacheHttpResponse(Utils.toJSON(fileList));
    }


utils.js
function sahiSendToServer(url){
    try {
        var rand = (new Date()).getTime() + Math.floor(Math.random() * (10000));
        var http = sahiCreateRequestObject();
        url = url + (url.indexOf("?") == -1 ? "?" : "&") + "t=" + rand;
        var post = url.substring(url.indexOf("?") + 1);
        url = url.substring(0, url.indexOf("?"));
        http.open("POST", url, false);
        http.send(post);
                 //here display not porperly 
                  alert(http.responseText);
        return http.responseText;
    } catch(ex) {
        sahiHandleException(ex)
    }
}


in playbak tabl file filed u will find T�C���A�b�v.sah

Comments

  • narayannarayan Administrators
    Hi Beesman,

    Thanks for pointing out. Having a look at this.

    Regards,
    Narayan
  • NoCacheHttpResponse.java
        public NoCacheHttpResponse(final String dataStr) {
            System.out.println("berfore:" + dataStr);
            try {
                //setNoCacheHeaders(dataStr.getBytes());    
                setNoCacheHeaders(dataStr.getBytes("UTF-8"));    
            } catch (Exception e) {
                e.printStackTrace();
            }
            
        }
    

    I modify NoCacheHttpResponse.java and the fileList displays properly .
    but I dont't know whether it causes other problems.
  • in my environment

    awt.toolkit=sun.awt.windows.WToolkit
    file.encoding=UTF-8
    file.encoding.pkg=sun.io
    file.separator=\
    java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
    java.awt.printerjob=sun.awt.windows.WPrinterJob
    java.class.version=50.0
    java.runtime.name=Java(TM) SE Runtime Environment
    java.runtime.version=1.6.0_14-b08
    java.specification.name=Java Platform API Specification
    java.specification.vendor=Sun Microsystems Inc.
    java.specification.version=1.6
    java.vendor=Sun Microsystems Inc.
    java.vendor.url=http://java.sun.com/
    java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi
    java.version=1.6.0_14
    java.vm.info=mixed mode, sharing
    java.vm.name=Java HotSpot(TM) Client VM
    java.vm.specification.name=Java Virtual Machine Specification
    java.vm.specification.vendor=Sun Microsystems Inc.
    java.vm.specification.version=1.0
    java.vm.vendor=Sun Microsystems Inc.
    java.vm.version=14.0-b16
    line.separator=

    os.arch=x86
    path.separator=;
    sun.arch.data.model=32
    sun.cpu.endian=little
    sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86
    sun.desktop=windows
    sun.io.unicode.encoding=UnicodeLittle
    sun.java.launcher=SUN_STANDARD
    sun.jnu.encoding=MS932

    sun.management.compiler=HotSpot Client Compiler
    sun.os.patch.level=Service Pack 3
    user.timezone=
    user.variant=
  • narayannarayan Administrators
    Hi Beesman,

    Your solution seems correct. I will verify and add this to the next build.

    Thanks,
    Narayan
  • this bug also should be verify.
    _debug(_sessionInfo().scriptPath);
    console
    Debug: secretPath\01 ???J??}(?????\03?_???\AutoTest02010311.sah
    
  • beesmanbeesman Members
    edited August 2010
    config.sah
    var $CORPRATION_NAME= "自动";

    test.sah
    _include("config.sah");
    _debug($CORPRATION_NAME);
    //���������C��������� is set
    _setValue(_textbox("name"), $CORPRATION_NAME);

    solution:
    i modify the file encoding of config.sah to utf-8 and it works fine
  • narayannarayan Administrators
    Yes Beesman,

    The file has to be saved correctly in UTF-8. If the file was created using Sahi while recording, it would have automatically used UTF-8. Please let me know if this was not the case.

    Regards,
    Narayan
  • #7 is the case what file encoding was wrong

    #6 havn't been solved.
Sign In or Register to comment.