Using Japanese and English strings, encodings



Hi! I'm new to lisp, a mediocre-but-trying-to-improve hobbyist
programmer, and just joined this newsgroup. If anyone can point me to
the answers for the following questions, I would greatly appreciate it.


1. In summary: How do I get a macro to turn into NOTHING at all (not
even NIL), or turn into multiple values (like is returned from the
VALUES function)?

A little explanation as to why I want this (If you know the Right
Way(TM) to do the following, please enlighten me):

I've been working a few small programs that use both Japanese and
English, and I keep wishing I could closely, reliable, and simply
couple two strings together (one in english and one in Japanese). In
the simplest case, I (naively?) dream of writing something like this:

(princ (eng "This is an english sentence.")
(jap "これは日本語の文章です。"))

Where ENG and JAP are little macros such that setting something to 'ENG
before the macro is evaluated will make it come out as:

(princ "This is an english sentence")

or in the case of a japanese compile, the sentence tagged with JAP.

So far, I have been getting by with using *features* and #+jap or #+eng
to remove before processing, but since sometimes I want to leave the
string as part of some larger, nested list structure, it gets to be a
pain. Or, *shudder*, what if I wanted to concatenate and print BOTH
strings?

Other times, I use something like the following, where LANG is the
macro that reads the CAR of each argument, and then evaluates to the
appropriate string.

(lang (eng "blahblah")
(jap "ブラブラ")) --> "blahblah"

This is a little better, as the LANG macro can even warn me if zero or
more than one string was found. But still, it's a bit annoying having
to always write that LANG, and it doesn't help me when I have certain
list structures. And of course, I can think of times when I have two or
more values I'd like to use, like the following,

(format t "Current Language: ~A~%My String:~A"
(lang (eng "English" "This is a waste of time.")
(jap "日本語"
"こりゃ時間の無駄だよな。")))

And I'm left scratching my head as to an elegant way to do this.

What is the elegant, lispy way to do multilanguage programs like this?

2. I ran into a little problem with the (very simple) CGI library I am
using. It keeps screwing up the EUC-JP encoding of any parameters I
pass the script. I traced the problem down to where the CGI script uses
CODE-CHAR to convert the correct EUC-JP encoded byte(s) into incorrect
UTF-8 byte(s). I think CLISP is using UTF-8 internally, despite my
command-line orders to use EUC-JP for everything. Everything else works
just fine.

How do I convince CODE-CHAR to use the EUC-JP character set? Or,
skipping over CODE-CHAR entirely, how do I use WRITE-BYTE to just write
the raw byte to a character stream and ignore what sort of (multi-byte
encoded) character it is?

3. Any recommendations on good, lightweight CGI/HTML libraries that
would work with EUC-JP?

.



Relevant Pages