You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

upper-case.js 953B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Special language-specific overrides.
  3. *
  4. * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
  5. *
  6. * @type {Object}
  7. */
  8. var LANGUAGES = {
  9. tr: {
  10. regexp: /[\u0069]/g,
  11. map: {
  12. '\u0069': '\u0130'
  13. }
  14. },
  15. az: {
  16. regexp: /[\u0069]/g,
  17. map: {
  18. '\u0069': '\u0130'
  19. }
  20. },
  21. lt: {
  22. regexp: /[\u0069\u006A\u012F]\u0307|\u0069\u0307[\u0300\u0301\u0303]/g,
  23. map: {
  24. '\u0069\u0307': '\u0049',
  25. '\u006A\u0307': '\u004A',
  26. '\u012F\u0307': '\u012E',
  27. '\u0069\u0307\u0300': '\u00CC',
  28. '\u0069\u0307\u0301': '\u00CD',
  29. '\u0069\u0307\u0303': '\u0128'
  30. }
  31. }
  32. }
  33. /**
  34. * Upper case a string.
  35. *
  36. * @param {String} str
  37. * @return {String}
  38. */
  39. module.exports = function (str, locale) {
  40. var lang = LANGUAGES[locale]
  41. str = str == null ? '' : String(str)
  42. if (lang) {
  43. str = str.replace(lang.regexp, function (m) { return lang.map[m] })
  44. }
  45. return str.toUpperCase()
  46. }