Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7676637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:14:41+00:00 2026-05-31T17:14:41+00:00

I need to replace accented characters in a string with their unaccented counterparts and

  • 0

I need to replace accented characters in a string with their unaccented counterparts and I implemented this http://lehelk.com/2011/05/06/script-to-remove-diacritics/.

var defaultDiacriticsRemovalMap = [
            {'base':'A', 'letters':/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},   
            /* ... 
            so on and so forth
            .... */
        ];

        var changes;
        function removeDiacritics (str) {
            if(!changes) {
                changes = defaultDiacriticsRemovalMap;
            }
            for(var i=0; i<changes.length; i++) {
                str = str.replace(changes[i].letters, changes[i].base);
            }
            return str.replace(/\s+/g, '_'); //space to dash
        }

This fails in IE 7 and 8 (works in every other browser) with the error 'changes[...].letters' is null or not an object on the line str = str.replace(changes[i].letters, changes[i].base);, and I have no idea why. I mean, I understand that the browser thinks that it had encountered a null value, but I fail to see how can this be the case.

I copied my code to a jsfiddle (it fires the same error there as well) so you can take a look at it.

http://jsfiddle.net/GggcU/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:14:42+00:00Added an answer on May 31, 2026 at 5:14 pm

    I’m not sure that this is you problem as you don’t have your whole code pasted, but I know for sure that IE7/8 throws an error if you add an extra comma after your last element of an array.

    So if you have something like this:

    var defaultDiacriticsRemovalMap = [
     {'base':'A'},   
     {'k1':'v1'},
     ...
     {'k_last':'v_last'}, // this last comma will break your js in IE7/8
    ];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need replace multiline string in file, like this: startString bla bla bla ...
I need to replace a string like 123456 to ,123456 . I tried this.
I need to replace many different sub-string in a string in the most efficient
I need to replace all System.Environment.Newline(s) in the string returned by my function with
I need to replace wrong symbols except chars and digits in my string with
need to replace <wiki>this page</wiki> to <a href='wiki/this_page'>this page</a> using callback function: text =
I need to replace imagesrc with the value stored in this object. However when
Need to replace colons wherever they're found in specific elements with id's. This works
i need to replace Sprite name = new Sprite(number1, number2, this.mScritteRegion.get(number3) { stuff_here };
I need to replace character (say) x with character (say) P in a string,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.