japanese text replacement did not work javascript in wordpress

I am using “pricer theme” in wordpress and I need to replace the English text to Japanese text. I replaced the text and this problem occurred.

HERE IS THE ORIGINAL CODE

Read More
<div class="box_content">    
    <script>
        jQuery(document).ready(function() {
            jQuery('.dd-submit-rating').click(function() {
                var id = jQuery(this).attr('rel');  
                var uprating = jQuery("#rating_me-" + id + " :selected").val();
                var reason = jQuery("#reason-" + id).val();
                if(reason.length < 10) { alert("<?php _e('Please input a longer description for your rating','PricerrTheme'); ?>"); return false; }
                jQuery.ajax({
                    type: "POST",
                    url: "<?php echo get_bloginfo('siteurl'); ?>/",
                    data: "rate_me=1&ids="+id+"&uprating="+uprating+"&reason="+reason,
                    success: function(msg){
                        jQuery("#post-" + id).hide('slow');
                    }
                });
                return false;
            });
//-------------------------
});
    </script>

And the original English pop up message

this is the original english pop up msg

AND HERE IS THE REPLACED JAPANESE TEXT

<script>
    jQuery(document).ready(function() {
        jQuery('.dd-submit-rating').click(function() {
            var id = jQuery(this).attr('rel');  
            var uprating = jQuery("#rating_me-" + id + " :selected").val();
            var reason = jQuery("#reason-" + id).val();
            if(reason.length < 10) { alert("<?php _e('もう少し文字を多めに(詳細)に評価してください。','PricerrTheme'); ?>"); return false; }
            jQuery.ajax({
                type: "POST",
                url: "<?php echo get_bloginfo('siteurl'); ?>/",
                data: "rate_me=1&ids="+id+"&uprating="+uprating+"&reason="+reason,
                success: function(msg){
                    jQuery("#post-" + id).hide('slow');
                }
            });
            return false;
        });
//-------------------------
});
</script>

WHEN I REPLACED JAPANESE TEXT IT'S SHOWS THIS POP-UP BOX MSG IN BROWSER

When I replaced Japanese text it shows this pop up box message in the browser.
Please help.

Related posts

1 comment

  1. Here is the solution of converting Unicode NCR to JavaScript escapes form:

    var strNCR = '&#x3082;&#x3046;&#x5C11;&#x3057;&#x6587;&#x5B57;&#x3092;&#x591A;&#x3081;&#x306B;&#xFF08;&#x8A73;&#x7D30;&#xFF09;&#x306B;&#x8A55;&#x4FA1;&#x3057;&#x3066;&#x304F;&#x3060;&#x3055;&#x3044;&#x3002;'; // Original Text: もう少し文字を多めに(詳細)に評価してください。
    
    alert(convertHexNCR2Char(strNCR));
    // or, in your case:
    alert(convertHexNCR2Char("<?php _e('もう少し文字を多めに(詳細)に評価してください。','PricerrTheme'); ?>"));
    
    function convertHexNCR2Char(str) {
        // converts a string containing &#x...; escapes to a string of characters
        // str: string, the input
    
        // convert up to 6 digit escapes to characters
        str = str.replace(/&#x([A-Fa-f0-9]{1,6});/g,
    
        function (matchstr, parens) {
            return hex2char(parens);
        });
        return str;
    }
    
    
    // =====
    // Helper functions
    function hex2char(hex) {
        // converts a single hex number to a character
        // note that no checking is performed to ensure that this is just a hex number, eg. no spaces etc
        // hex: string, the hex codepoint to be converted
        var result = '';
        var n = parseInt(hex, 16);
        if (n <= 0xFFFF) {
            result += String.fromCharCode(n);
        } else if (n <= 0x10FFFF) {
            n -= 0x10000
            result += String.fromCharCode(0xD800 | (n >> 10)) + String.fromCharCode(0xDC00 | (n & 0x3FF));
        } else {
            result += 'hex2Char error: Code point out of range: ' + dec2hex(n);
        }
        return result;
    }
    
    function dec2hex(textString) {
        return (textString + 0).toString(16).toUpperCase();
    }
    

    Working JSFiddle

    Code snippets are adapted from Unicode code converter, a free tool to convert to and from different Unicode formats.

Comments are closed.