Search in localized language breaks compatability

Posted by: zhoubing.yang on 4 May 2022, 4:06 am EST

  • Posted 4 May 2022, 4:06 am EST

    Hi,
    We use encodeURIComponent to sanitize the search input, search in localized language was supported back in v12 but no longer works in v15

    getSearchCondition(searchOptions) {
    var sheet = this.spread.getActiveSheet();
    $.fn.defaulSearchOptions = {
    rowStart: 0,
    columnStart: 0,
    rowEnd: sheet.getRowCount(),
    columnEnd: sheet.getColumnCount()
    };

    searchOptions = $.extend({}, $.fn.defaulSearchOptions, searchOptions);
    var searchCondition = new GC.Spread.Sheets.Search.SearchCondition();
    searchCondition.searchString=encodeURIComponent(searchOptions.searchString);
    searchCondition.searchOrder = GC.Spread.Sheets.Search.SearchOrder.zOrder;
    searchCondition.searchTarget = GC.Spread.Sheets.Search.SearchFoundFlags.cellText;
    searchCondition.rowStart = searchOptions.rowStart;
    searchCondition.columnStart = searchOptions.columnStart;
    searchCondition.rowEnd = searchOptions.rowEnd;
    searchCondition.columnEnd = searchOptions.columnEnd;
    searchCondition.startSheetIndex = this.spread.getActiveSheetIndex();
    searchCondition.endSheetIndex = this.spread.getActiveSheetIndex();
    searchCondition.searchFlags = GC.Spread.Sheets.Search.SearchFlags.ignoreCase | GC.Spread.Sheets.Search.SearchFlags.useWildCards;
    return searchCondition;
    }
    [/code]
  • Replied 4 May 2022, 4:26 am EST


    getSearchCondition(searchOptions) {
    var sheet = this.spread.getActiveSheet();
    $.fn.defaulSearchOptions = {
    rowStart: 0,
    columnStart: 0,
    rowEnd: sheet.getRowCount(),
    columnEnd: sheet.getColumnCount()
    };

    searchOptions = $.extend({}, $.fn.defaulSearchOptions, searchOptions);
    var searchCondition = new GC.Spread.Sheets.Search.SearchCondition();
    searchCondition.searchString=encodeURIComponent(searchOptions.searchString);
    searchCondition.searchOrder = GC.Spread.Sheets.Search.SearchOrder.zOrder;
    searchCondition.searchTarget = GC.Spread.Sheets.Search.SearchFoundFlags.cellText;
    searchCondition.rowStart = searchOptions.rowStart;
    searchCondition.columnStart = searchOptions.columnStart;
    searchCondition.rowEnd = searchOptions.rowEnd;
    searchCondition.columnEnd = searchOptions.columnEnd;
    searchCondition.startSheetIndex = this.spread.getActiveSheetIndex();
    searchCondition.endSheetIndex = this.spread.getActiveSheetIndex();
    searchCondition.searchFlags = GC.Spread.Sheets.Search.SearchFlags.ignoreCase | GC.Spread.Sheets.Search.SearchFlags.useWildCards;
    return searchCondition;
    }
  • Replied 4 May 2022, 4:56 pm EST

    Hi Zhoubing,

    We tested out with the latest version of SpreadJS and it seems to be working fine at our end.

    Please refer to the following sample that I have created for you and let us know if we are missing any step in order to replicate the issue at our end: https://jscodemine.grapecity.com/share/4hhM3N3RSUu2gd1e_SgAIA/

    If the issue still persists for you, please share a working sample and the steps you have followed so that we can investigate it at our end and assist you accordingly. You can also modify the above sample and share with us.

    Regards
    Ankit
  • Replied 5 May 2022, 1:15 am EST

    Hi Ankit, thanks for this quick demo.
    This is not the default behavior we are expecting.
    The result needs to find "шеллы" instead of "%D1%88%D0%B5%D0%BB%D0%BB%D1%8B"
  • Replied 9 May 2022, 9:25 pm EST

    Hi Zhoubing,

    Apologies for the late reply. This is the expected behavior. When you pass a string to the encodeURIComponent method, it encodes the string by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character.

    When you use
     searchCondition.searchString = encodeURIComponent("шеллы"); 
    , you are passing the encoded string and hence SpreadJS will only search for encoded string. In Excel also, if you pass the encoded string, it will search for encoded string.

    If you want to search for "шеллы" simply, use
    searchCondition.searchString = "шеллы".
    I hope this clarifies your query.

    Please let us know if you need further assistance on this. We would be happy to help you.

    Regards
    Ankit
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels