Replace method doesn't work

后端 未结 4 810
鱼传尺愫
鱼传尺愫 2020-11-21 05:35

I want to replace the smart quotes like , , and to regular quotes. Also, I wanted to replace the ©,

4条回答
  •  我在风中等你
    2020-11-21 06:02

    To replace all regular quotes with smart quotes, I am using a similar function. You must specify the CharCode as some different computers/browsers default settings may identify the plain characters differently ("",",',').

    Using the CharCode with call the ASCII character, which will eliminate the room for error across different browsers, and operating systems. This is also helpful for bilingual use (accents, etc.).

    To replace smart quotes with SINGLE QUOTES

    function unSmartQuotify(n){
        var name = n;
        var apos = String.fromCharCode(39);
        while (n.indexOf("'") > -1)
            name = name.replace("'" , apos);
        return name;
    } 
    

    To find the other ASCII values you may need. Check here.

提交回复
热议问题