Is there any way to set default source encoding in Lift2.0-scala280 ?

35 views
Skip to first unread message

pomu0325

unread,
Feb 2, 2010, 9:00:47 PM2/2/10
to Lift
Hi, I'm quite a newbie to Lift. I'm now trying to port my first Lift
application from Lift1.0.2 to latest Lift2.0-scala280, and faced a
problem relating to source encoding.

I managed to merge pom.xml and some codes on Boot.scala, and succeeded
to build my application, but when I access to it from browser, it
displays:

Message: java.nio.charset.UnmappableCharacterException: Input length =
2
java.nio.charset.CoderResult.throwException(CoderResult.java:261)
sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:319)
sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
java.io.InputStreamReader.read(InputStreamReader.java:167)
java.io.BufferedReader.fill(BufferedReader.java:136)
java.io.BufferedReader.read(BufferedReader.java:157)
scala.io.BufferedSource$$anonfun$1$$anonfun$apply$1.apply
(BufferedSource.scala:29)
scala.io.BufferedSource$$anonfun$1$$anonfun$apply$1.apply
(BufferedSource.scala:29)
scala.io.Codec.wrap(Codec.scala:65)
scala.io.BufferedSource$$anonfun$1.apply(BufferedSource.scala:29)
scala.io.BufferedSource$$anonfun$1.apply(BufferedSource.scala:29)
scala.collection.Iterator$$anon$13.next(Iterator.scala:145)
scala.collection.Iterator$$anon$24.hasNext(Iterator.scala:435)
scala.collection.Iterator$$anon$19.hasNext(Iterator.scala:326)
scala.io.Source.hasNext(Source.scala:209)
net.liftweb.util.PCDataXmlParser$$anonfun$apply$2$$anonfun$apply
$4.apply(PCDataMarkupParser.scala:184)

... and more

I traced Lift source and found out that "Codec" argument is not
passed to Source.fromInputStream(in) at PCDataMarkupParser.scala(l.
182). "Codec" api seems to be introduced newly in Scala 2.8, and
Source.fromInputStream() uses Codec.default as a implicit argument.

My problem here, is I'm using utf-8 for write *.html templates, but
my Codec.default is "MS932"(Japanese characterset in Windows), so
failing to decode my template files. I looked through Scala lib
source, and found out Codec.default it is actually an alias to
java.lang.Charset.getDefault(), so I just set -Djava.encoding=utf-8 to
MVN_OPTS and solved the problem, but considering deployment, I don't
think it's a smart way.

BTW, I confirmed this does not occur on Lift2.0-scala2.7.7. I think
default source encoding should be somehow configurable in Lift to
achieve portability.

Kind regards,

Pomu TAKEUCHI

Timothy Perrett

unread,
Feb 3, 2010, 4:54:16 AM2/3/10
to lif...@googlegroups.com
Do not use the 2.8 port of Lift yet... its mostly broken. Please use 2.7.7 until the official 2.8 release is out.

Cheers, Tim

> --
> You received this message because you are subscribed to the Google Groups "Lift" group.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
>
>

TAKEUCHI POMU

unread,
Feb 3, 2010, 6:50:35 AM2/3/10
to liftweb
Thanks for the comment. I was too much hasted... I'm going to use
2.7.7 for a while.

Pomu TAKEUCHI

2010/2/3 Timothy Perrett <tim...@getintheloop.eu>:

David Pollak

unread,
Feb 3, 2010, 2:31:09 PM2/3/10
to lif...@googlegroups.com
On Wed, Feb 3, 2010 at 1:54 AM, Timothy Perrett <tim...@getintheloop.eu> wrote:
Do not use the 2.8 port of Lift yet... its mostly broken. Please use 2.7.7 until the official 2.8 release is out.

Although this is the kind of bug we want to find.

For production sites, I would strongly recommend sicking with 2.7.7

If you are skilled with Scala and want to try Lift and 2.8, I encourage you to do so.  This is the kind of corner-case that we want to find during testing.
 



--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

Indrajit Raychaudhuri

unread,
Feb 4, 2010, 1:52:54 AM2/4/10
to lif...@googlegroups.com
Takeuchi-san,

Can you please set project.build.sourceEncoding=UTF-8 in your pom.xml
and check if it works?

You can set project.build.sourceEncoding in pom.xml the following way:

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
...
...
</properties>

Cheers, Indrajit

> <mailto:lif...@googlegroups.com>.


> > To unsubscribe from this group, send email to
> liftweb+u...@googlegroups.com

> <mailto:liftweb%2Bunsu...@googlegroups.com>.


> > For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
> >
> >
>
> --
> You received this message because you are subscribed to the Google
> Groups "Lift" group.
> To post to this group, send email to lif...@googlegroups.com

> <mailto:lif...@googlegroups.com>.


> To unsubscribe from this group, send email to
> liftweb+u...@googlegroups.com

> <mailto:liftweb%2Bunsu...@googlegroups.com>.


> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>
>
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Surf the harmonics
>

TAKEUCHI POMU

unread,
Feb 4, 2010, 2:18:50 AM2/4/10
to liftweb
Indrajit,

Thanks for the advise. I already tried that, but not worked on *.html
templates. Exception occurs at runtime, not at build.
>  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

Regards,
Pomu TAKEUCHI

2010/2/4 Indrajit Raychaudhuri <indr...@gmail.com>:

David Pollak

unread,
Feb 8, 2010, 3:12:48 PM2/8/10
to lif...@googlegroups.com
Please open a ticket at https://liftweb.assembla.com/spaces/liftweb/tickets on this issue and assign it to me.

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.

Atsuhiko Yamanaka

unread,
Feb 24, 2010, 8:49:35 PM2/24/10
to lif...@googlegroups.com
Hi,

On Wed, Feb 3, 2010 at 11:00 AM, pomu0325 <pomu...@gmail.com> wrote:
> Hi, I'm quite a newbie to Lift. I'm now trying to port my first Lift
> application from Lift1.0.2 to latest Lift2.0-scala280, and faced a
> problem relating to source encoding.

...


>  My problem here, is I'm using utf-8 for write *.html templates, but
> my Codec.default is "MS932"(Japanese characterset in Windows), so
> failing to decode my template files. I looked through Scala lib
> source, and found out Codec.default it is actually an alias to
> java.lang.Charset.getDefault(), so I just set -Djava.encoding=utf-8 to
> MVN_OPTS and solved the problem, but considering deployment, I don't
> think it's a smart way.

FYI, the reported problem was fixed at last night, thanks to hseeberger,
as follows,
http://www.assembla.com/spaces/liftweb/tickets/364
http://github.com/dpp/liftweb/commit/4bfe8579c5283642c9c059b55f98236155f2d423


Sincerely,
--
Atsuhiko Yamanaka
JCraft,Inc.
1-14-20 HONCHO AOBA-KU,
SENDAI, MIYAGI 980-0014 Japan.
Tel +81-22-723-2150
+1-415-578-3454
Skype callto://jcraft/
Twitter: @ymnk

Reply all
Reply to author
Forward
0 new messages