Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Javascript] Chuyển tiếng Việt tổ hợp sang dựng sẵn
function compoundUnicode(str) {
return `${str}`
.replace(/\u0065\u0309/g, '\u1EBB') // ẻ
.replace(/\u0065\u0301/g, '\u00E9') // é
.replace(/\u0065\u0300/g, '\u00E8') // è
.replace(/\u0065\u0323/g, '\u1EB9') // ẹ
.replace(/\u0065\u0303/g, '\u1EBD') // ẽ
.replace(/\u00EA\u0309/g, '\u1EC3') // ể
.replace(/\u00EA\u0301/g, '\u1EBF') // ế
.replace(/\u00EA\u0300/g, '\u1EC1') // ề
.replace(/\u00EA\u0323/g, '\u1EC7') // ệ
.replace(/\u00EA\u0303/g, '\u1EC5') // ễ
.replace(/\u0079\u0309/g, '\u1EF7') // ỷ
.replace(/\u0079\u0301/g, '\u00FD') // ý
.replace(/\u0079\u0300/g, '\u1EF3') // ỳ
.replace(/\u0079\u0323/g, '\u1EF5') // ỵ
.replace(/\u0079\u0303/g, '\u1EF9') // ỹ
.replace(/\u0075\u0309/g, '\u1EE7') // ủ
.replace(/\u0075\u0301/g, '\u00FA') // ú
.replace(/\u0075\u0300/g, '\u00F9') // ù
.replace(/\u0075\u0323/g, '\u1EE5') // ụ
.replace(/\u0075\u0303/g, '\u0169') // ũ
.replace(/\u01B0\u0309/g, '\u1EED') // ử
.replace(/\u01B0\u0301/g, '\u1EE9') // ứ
.replace(/\u01B0\u0300/g, '\u1EEB') // ừ
.replace(/\u01B0\u0323/g, '\u1EF1') // ự
.replace(/\u01B0\u0303/g, '\u1EEF') // ữ
.replace(/\u0069\u0309/g, '\u1EC9') // ỉ
.replace(/\u0069\u0301/g, '\u00ED') // í
.replace(/\u0069\u0300/g, '\u00EC') // ì
.replace(/\u0069\u0323/g, '\u1ECB') // ị
.replace(/\u0069\u0303/g, '\u0129') // ĩ
.replace(/\u006F\u0309/g, '\u1ECF') // ỏ
.replace(/\u006F\u0301/g, '\u00F3') // ó
.replace(/\u006F\u0300/g, '\u00F2') // ò
.replace(/\u006F\u0323/g, '\u1ECD') // ọ
.replace(/\u006F\u0303/g, '\u00F5') // õ
.replace(/\u01A1\u0309/g, '\u1EDF') // ở
.replace(/\u01A1\u0301/g, '\u1EDB') // ớ
.replace(/\u01A1\u0300/g, '\u1EDD') // ờ
.replace(/\u01A1\u0323/g, '\u1EE3') // ợ
.replace(/\u01A1\u0303/g, '\u1EE1') // ỡ
.replace(/\u00F4\u0309/g, '\u1ED5') // ổ
.replace(/\u00F4\u0301/g, '\u1ED1') // ố
.replace(/\u00F4\u0300/g, '\u1ED3') // ồ
.replace(/\u00F4\u0323/g, '\u1ED9') // ộ
.replace(/\u00F4\u0303/g, '\u1ED7') // ỗ
.replace(/\u0061\u0309/g, '\u1EA3') // ả
.replace(/\u0061\u0301/g, '\u00E1') // á
.replace(/\u0061\u0300/g, '\u00E0') // à
.replace(/\u0061\u0323/g, '\u1EA1') // ạ
.replace(/\u0061\u0303/g, '\u00E3') // ã
.replace(/\u0103\u0309/g, '\u1EB3') // ẳ
.replace(/\u0103\u0301/g, '\u1EAF') // ắ
.replace(/\u0103\u0300/g, '\u1EB1') // ằ
.replace(/\u0103\u0323/g, '\u1EB7') // ặ
.replace(/\u0103\u0303/g, '\u1EB5') // ẵ
.replace(/\u00E2\u0309/g, '\u1EA9') // ẩ
.replace(/\u00E2\u0301/g, '\u1EA5') // ấ
.replace(/\u00E2\u0300/g, '\u1EA7') // ầ
.replace(/\u00E2\u0323/g, '\u1EAD') // ậ
.replace(/\u00E2\u0303/g, '\u1EAB') // ẫ
.replace(/\u0045\u0309/g, '\u1EBA') // Ẻ
.replace(/\u0045\u0301/g, '\u00C9') // É
.replace(/\u0045\u0300/g, '\u00C8') // È
.replace(/\u0045\u0323/g, '\u1EB8') // Ẹ
.replace(/\u0045\u0303/g, '\u1EBC') // Ẽ
.replace(/\u00CA\u0309/g, '\u1EC2') // Ể
.replace(/\u00CA\u0301/g, '\u1EBE') // Ế
.replace(/\u00CA\u0300/g, '\u1EC0') // Ề
.replace(/\u00CA\u0323/g, '\u1EC6') // Ệ
.replace(/\u00CA\u0303/g, '\u1EC4') // Ễ
.replace(/\u0059\u0309/g, '\u1EF6') // Ỷ
.replace(/\u0059\u0301/g, '\u00DD') // Ý
.replace(/\u0059\u0300/g, '\u1EF2') // Ỳ
.replace(/\u0059\u0323/g, '\u1EF4') // Ỵ
.replace(/\u0059\u0303/g, '\u1EF8') // Ỹ
.replace(/\u0055\u0309/g, '\u1EE6') // Ủ
.replace(/\u0055\u0301/g, '\u00DA') // Ú
.replace(/\u0055\u0300/g, '\u00D9') // Ù
.replace(/\u0055\u0323/g, '\u1EE4') // Ụ
.replace(/\u0055\u0303/g, '\u0168') // Ũ
.replace(/\u01AF\u0309/g, '\u1EEC') // Ử
.replace(/\u01AF\u0301/g, '\u1EE8') // Ứ
.replace(/\u01AF\u0300/g, '\u1EEA') // Ừ
.replace(/\u01AF\u0323/g, '\u1EF0') // Ự
.replace(/\u01AF\u0303/g, '\u1EEE') // Ữ
.replace(/\u0049\u0309/g, '\u1EC8') // Ỉ
.replace(/\u0049\u0301/g, '\u00CD') // Í
.replace(/\u0049\u0300/g, '\u00CC') // Ì
.replace(/\u0049\u0323/g, '\u1ECA') // Ị
.replace(/\u0049\u0303/g, '\u0128') // Ĩ
.replace(/\u004F\u0309/g, '\u1ECE') // Ỏ
.replace(/\u004F\u0301/g, '\u00D3') // Ó
.replace(/\u004F\u0300/g, '\u00D2') // Ò
.replace(/\u004F\u0323/g, '\u1ECC') // Ọ
.replace(/\u004F\u0303/g, '\u00D5') // Õ
.replace(/\u01A0\u0309/g, '\u1EDE') // Ở
.replace(/\u01A0\u0301/g, '\u1EDA') // Ớ
.replace(/\u01A0\u0300/g, '\u1EDC') // Ờ
.replace(/\u01A0\u0323/g, '\u1EE2') // Ợ
.replace(/\u01A0\u0303/g, '\u1EE0') // Ỡ
.replace(/\u00D4\u0309/g, '\u1ED4') // Ổ
.replace(/\u00D4\u0301/g, '\u1ED0') // Ố
.replace(/\u00D4\u0300/g, '\u1ED2') // Ồ
.replace(/\u00D4\u0323/g, '\u1ED8') // Ộ
.replace(/\u00D4\u0303/g, '\u1ED6') // Ỗ
.replace(/\u0041\u0309/g, '\u1EA2') // Ả
.replace(/\u0041\u0301/g, '\u00C1') // Á
.replace(/\u0041\u0300/g, '\u00C0') // À
.replace(/\u0041\u0323/g, '\u1EA0') // Ạ
.replace(/\u0041\u0303/g, '\u00C3') // Ã
.replace(/\u0102\u0309/g, '\u1EB2') // Ẳ
.replace(/\u0102\u0301/g, '\u1EAE') // Ắ
.replace(/\u0102\u0300/g, '\u1EB0') // Ằ
.replace(/\u0102\u0323/g, '\u1EB6') // Ặ
.replace(/\u0102\u0303/g, '\u1EB4') // Ẵ
.replace(/\u00C2\u0309/g, '\u1EA8') // Ẩ
.replace(/\u00C2\u0301/g, '\u1EA4') // Ấ
.replace(/\u00C2\u0300/g, '\u1EA6') // Ầ
.replace(/\u00C2\u0323/g, '\u1EAC') // Ậ
.replace(/\u00C2\u0303/g, '\u1EAA') // Ẫ
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.