- 
      
- 
        Save yeungon/84dcc9757cd8d832f07c2f7a00f7442c to your computer and use it in GitHub Desktop. 
    Remove vietnamese accent javascript / Bỏ dấu tiếng Việt
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function stringToSlug(str) { | |
| // remove accents | |
| var from = "àáãảạăằắẳẵặâầấẩẫậèéẻẽẹêềếểễệđùúủũụưừứửữựòóỏõọôồốổỗộơờớởỡợìíỉĩịäëïîöüûñçýỳỹỵỷ", | |
| to = "aaaaaaaaaaaaaaaaaeeeeeeeeeeeduuuuuuuuuuuoooooooooooooooooiiiiiaeiiouuncyyyyy"; | |
| for (var i=0, l=from.length ; i < l ; i++) { | |
| str = str.replace(RegExp(from[i], "gi"), to[i]); | |
| } | |
| str = str.toLowerCase() | |
| .trim() | |
| .replace(/[^a-z0-9\-]/g, '-') | |
| .replace(/-+/g, '-'); | |
| return str; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment