This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Encoding and unescaped-data


(I forgot to CC the list)

---------- Forwarded message ----------
From: Daniel Terhorst <daniel.s.terhorst@gmail.com>
Date: Aug 22, 2007 6:15 PM
Subject: Re: Encoding and unescaped-data
To: Luis Casillas <luis@casillas.org>


The file.encoding seems to be Cp1252. :/

I'm not sure how the port is being opened because it seems to happen
automatically. Anything that makes it up to the top level (the
ultimate result of the base set of expressions) gets sent to the
client. I'm using Tomcat 6 with kawa-1.9.1.jar.

I set port-char-encoding at the very top of the example code I gave
before, right after:

;; -*- scheme -*-

and right before the first function definition (new code below).



I'll take a look at passing arguments to the Java process.

Thanks,
-- Daniel Terhorst




;; -*- scheme -*-

(set! port "UTF-8")
(set! port-char-encoding "UTF-8")

(define (bytes->string/utf-8 bytes)
  (<string> (<java.lang.String> bytes
                                0
                                bytes:length
                                "UTF-8")))

(let* ((data (string-append "<b>"
                            (bytes->string/utf-8 (<byte[]> 206 187))
                            "</b>")))
  (values-append (unescaped-data "<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
                 data ", " (unescaped-data data)))

#\newline





On 8/22/07, Luis Casillas <luis@casillas.org> wrote:
>
> $LANG is an OS-specific way of telling Java which encoding to use, so
> I'm not surprised you run into trouble.  What do you get when you run
> the following Kawa code in your Windows laptop?
>
>     (<java.lang.System>:getProperty "file.encoding")
>
> If you have control over what arguments are passed to the Java
> process that's running your code, you may want to add a "-
> Dfile.encoding=UTF-8" argument.
>
> Other questions:
>
> 1. How is the port that you're using to output the data being opened?
>
> 2. When are you setting the port-char-encoding, relative to when the
> port is being opened?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]