mario-goulart / awful

awful provides an application and an extension to ease the development of web-based applications in CHICKEN Scheme
http://wiki.call-cc.org/egg/awful
Other
75 stars 6 forks source link

utf8 support #5

Open ZelphirKaltstahl opened 7 years ago

ZelphirKaltstahl commented 7 years ago

I am running a little tutorial project with awful, outputting Chinese characters using SXML. For example as follows:

I am requiring the utf8 extension:

(require-extension utf8)

Then one example part goes as follows:

(td ,(render-hanci (simplified a-word)))

Where render-hanci is:

(define (render-hanci hanci)
  (define (render-hanzi hanzi)
    `(div (@ (class "hanzi-container"))
          (p (@ (class "hanzi"))
             ,hanzi)))
  (map render-hanzi (utf8-string->list hanci)))

("hanci" meaning "word" and "hanzi" meaning character.) Where utf8-string->list is:

(define (utf8-string->list a-string)
  (define (iter the-string ind result)
    (cond [(< ind (string-length the-string))
           (display "current character is: ") (display (string-ref the-string ind)) (newline)
           (iter the-string (+ ind 1) (cons (string-ref the-string ind) result))]
          [else
           result]))
  (reverse (iter a-string 0 (list))))

This is a procedure, which I created to check what the single characters of the list are and to see if my understanding of how to handle utf8 is correct. The characters being displayed when this code runs are the correct Chinese characters. However, when I check on the website, I get wrong characters. To show what I mean I will add a screenshot:

image

I can post my whole code (here it is), if needed in a repository. However, I'd like to know, if there is any reason, why awful might/cannot not support unicode characters out of the box in SXML expressions.

Info

mario-goulart commented 7 years ago

Hello Zelphir,

Thanks for the detailed report. I don't know for sure what the cause of the problem is, but it seems to be related to CHICKEN (I can reproduce the issue with the latest version, 4.12.0). I've created a ticket in CHICKEN's bug tracker: http://bugs.call-cc.org/ticket/1374 .

All the best. Mario

ZelphirKaltstahl commented 7 years ago

Thanks for that. I am not sure I am using the utf8 extension correctly, as I do not fully understand how use and require-extension and import work yet. However, if you saw no mistake there, maybe I did it right.