Next: , Previous: , Up: Usage Examples   [Contents][Index]

4.2 Hello World UTF8

This example only differs from the previous in that the “Content-type” indicates UTF8 encoded data, and the hello world sent is selected at random from a list of different languages.

;;; hello-world-utf8.el --- utf8 hello world server using Emacs Web Server
 (lambda (request)
   (with-slots (process headers) request
     (let ((hellos '("こんにちは"
                     "góðan dag"
                     "hyvää päivää"
                     "Γεια σας"
       (ws-response-header process 200
         '("Content-type" . "text/plain; charset=utf-8"))
       (process-send-string process
         (concat (nth (random (length hellos)) hellos) " world")))))