Skip to content Skip to sidebar Skip to footer

How Can Be Request Variables Encoded By Encodeuricomponent With Iso-8859-1 Charset And Not Utf-8?

I working on website with ISO-8859-1 charset. Request should be encoded partly by encodeURIComponent() , but this function encode with utf-8. How can be request variables encoded b

Solution 1:

I've made a script for escaping Windows-1250 characters. You can create a translation table by yourself or generate from Wikipedia with a translation table generation script I used. The script should work at least on IE 7, FF 3.6 and Opera 11 (haven't tested on other browsers).

Example code for jQuery:

var sBaseUrl = 'ajax.script.php';
var oData = {
    some_param : 'Zażółć gęślą jaźń',
    other_param : '1',
};

// build urlvar url = localBuildURL(sBaseUrl, oData);

// get
$.ajax({
    url: url,
    dataType: 'text',   // JSON doesn't always parse...success: function(txt, status, xhr)
    {
        // do something with txt// or parse with: data = $.parseJSON(txt);
    }
});

Edit: Actually... No translation table is needed for ISO-8591-1. All characters in it are one byte only. The escape function should be sufficient.

Solution 2:

You should be fine. ISO-8859-1 I believe is completely encapsulated in UTF-8 with no issues.

Post a Comment for "How Can Be Request Variables Encoded By Encodeuricomponent With Iso-8859-1 Charset And Not Utf-8?"