unicode.scm 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. ;;; unicode.scm --- The R6RS Unicode library
  2. ;; Copyright (C) 2010 Free Software Foundation, Inc.
  3. ;;
  4. ;; This library is free software; you can redistribute it and/or
  5. ;; modify it under the terms of the GNU Lesser General Public
  6. ;; License as published by the Free Software Foundation; either
  7. ;; version 3 of the License, or (at your option) any later version.
  8. ;;
  9. ;; This library is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. ;; Lesser General Public License for more details.
  13. ;;
  14. ;; You should have received a copy of the GNU Lesser General Public
  15. ;; License along with this library; if not, write to the Free Software
  16. ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. (library (rnrs unicode (6))
  18. (export char-upcase
  19. char-downcase
  20. char-titlecase
  21. char-foldcase
  22. char-ci=?
  23. char-ci<?
  24. char-ci>?
  25. char-ci<=?
  26. char-ci>=?
  27. char-alphabetic?
  28. char-numeric?
  29. char-whitespace?
  30. char-upper-case?
  31. char-lower-case?
  32. char-title-case?
  33. char-general-category
  34. string-upcase
  35. string-downcase
  36. string-titlecase
  37. string-foldcase
  38. string-ci=?
  39. string-ci<?
  40. string-ci>?
  41. string-ci<=?
  42. string-ci>=?
  43. string-normalize-nfd
  44. string-normalize-nfkd
  45. string-normalize-nfc
  46. string-normalize-nfkc)
  47. (import (only (guile) char-upcase
  48. char-downcase
  49. char-titlecase
  50. char-ci=?
  51. char-ci<?
  52. char-ci>?
  53. char-ci<=?
  54. char-ci>=?
  55. char-alphabetic?
  56. char-numeric?
  57. char-whitespace?
  58. char-upper-case?
  59. char-lower-case?
  60. char-set-contains?
  61. char-set:title-case
  62. char-general-category
  63. char-upcase
  64. char-downcase
  65. char-titlecase
  66. string-upcase
  67. string-downcase
  68. string-titlecase
  69. string-ci=?
  70. string-ci<?
  71. string-ci>?
  72. string-ci<=?
  73. string-ci>=?
  74. string-normalize-nfd
  75. string-normalize-nfkd
  76. string-normalize-nfc
  77. string-normalize-nfkc)
  78. (rnrs base (6)))
  79. (define (char-foldcase char)
  80. (if (or (eqv? char #\460) (eqv? char #\461))
  81. char (char-downcase (char-upcase char))))
  82. (define (char-title-case? char) (char-set-contains? char-set:title-case char))
  83. (define (string-foldcase str) (string-downcase (string-upcase str)))
  84. )