Thanks Michael, The behavior of ' in Struts messages resources was turning me crazy. Particularly when a resource string was used to localize javascript code, where I use single quotes as string separator and frequently had syntax errors due to quotes disappearing from the retrieved string. Now, I have found in java.text.MessageFormat that the quote character is used as escape char in format string. And Struts processes the strings from the resource for argument substitution... Thus this strange and undocumented (in Struts) behavior. Perhaps a quote from the JDK doc could be added in the <struts:message> documentation: In strings, single quotes can be used to quote the "{" (curly brace) if necessary. A real single quote is represented by ''. Inside a messageFormatElement, quotes are not removed Thanks again. Pierre Metras ----- Original Message ----- From: "Michael Westbay" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, November 04, 2000 10:38 AM Subject: Re: Can't obtain quote characters from struts message file > M$BqU(Bras-san wrote: > > > I posted this problem one month ago but I've only found a strange solution. > > Are other having such a behavior? > > > > My tomcat+struts web application reads message tag strings from a property > > file. In the default message file, that contains French sentences for the > > moment, when the messages contains quotes ( ' ), these quotes disapear on > > the HTML page. I traced the problem to the function reading the messages > > from the property file. > > [...] > > As a last test, I tried to double the quote as in "l''$Bim(Bission" (that's two > > quotes, and not a double-quote). And then it worked! I have "l'$Bim(Bission" on > > the displayed HTML page. > > Are you putting this string through a java.text.MessageFormat.format(...) > function? I've had this problem with format()ed strings read from > ResourceBundles in the past. It's the MessageFormat that causes the single > quotes to require the two single quotes to escape. When I don't put the > string through the MessageFormat.format() function, doubling single quotes > aren't required. > > -- > Michael Westbay > Work: Beacon-IT http://www.beacon-it.co.jp/ > Home: http://www.seaple.icc.ne.jp/~westbay > Commentary: http://www.japanesebaseball.com/ >

Reply via email to