[stringtemplate-interest] Different charsets for template attributes
Terence Parr
parrt at cs.usfca.edu
Tue Jun 12 19:04:59 PDT 2007
Hi. I see
/**
* FIXME: Dannish does not work if typed directly in with
default file
* encoding on windows. The character needs to be escaped as
bellow.
* Please correct to escape the correct charcter.
*/
public void test8BitEuroChars() throws Exception {
StringTemplate e = new StringTemplate(
"Danish: \u0143 char"
);
e = e.getInstanceOf();
String expecting = "Danish: \u0143 char";
assertEquals(expecting, e.toString());
}
public void test16BitUnicodeChar() throws Exception {
StringTemplate e = new StringTemplate(
"DINGBAT CIRCLED SANS-SERIF DIGIT ONE: \u2780"
);
e = e.getInstanceOf();
String expecting = "DINGBAT CIRCLED SANS-SERIF DIGIT ONE: \u2780";
assertEquals(expecting, e.toString());
}
Hmm...we need to set the encoding. You need to set (in
StringTemplateGroup):
/** How are the files encoded (ascii, UTF8, ...)? You might want to
read
* UTF8 for example on an ascii machine.
*/
String fileCharEncoding = System.getProperty("file.encoding");
use setFileCharEncoding().
Ter
On Jun 12, 2007, at 4:42 PM, Ezra Nugroho wrote:
>
> Thank you,
>
> Mind giving me the test name?
> I did some searching, but I couldn't find it.
>
> Thanks
> Ezra
>
>
> On Tue, 2007-06-12 at 15:57 -0700, Terence Parr wrote:
>> Hi. THe templates should handle different encodings and unicode no
>> problem in java. As for attribute names, no problem. java strings.
>>
>> Check out the teststringtemplate.java. It's got one test.
>>
>> Ter
>> On Jun 11, 2007, at 5:17 PM, Ezra Nugroho wrote:
>>
>>>
>>> StringTemplate experts,
>>>
>>>
>>> I am evaluating StringTemplate for in our email manager.
>>> One of our requirements is to be able to send email in multiple
>>> languages, and multiple charsets.
>>>
>>> When I browse the API docs, it doesn't seem that I can change the
>>> charset when setting an attribute.
>>>
>>> Has anyone use a different charset for attributes before?
>>> Would StringTemplate work if the template is written in a different
>>> charset?
>>>
>>>
>>> Thank you,
>>> Ezra
>>>
>>> _______________________________________________
>>> stringtemplate-interest mailing list
>>> stringtemplate-interest at antlr.org
>>> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
>>
>> _______________________________________________
>> stringtemplate-interest mailing list
>> stringtemplate-interest at antlr.org
>> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list