You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Graham <dg...@hotmail.com> on 2003/05/10 20:11:33 UTC

Re: Unicode characters in mask var value - Urgent, Please help...

I think the match is correct because it has to escape the \ you used to 
designate the unicode character.  It's more likely that the validator is 
trying to match the literal string \u05d0 instead of whatever character 
that's supposed to represent.  Try typing in \u05d0 and see if you pass 
validation to verify this.

David


>From: Erez Efrati <er...@netmedia.net.il>
>Reply-To: "Struts Users Mailing List" <st...@jakarta.apache.org>
>To: 'Struts Users Mailing List' <st...@jakarta.apache.org>
>Subject: Unicode characters in mask var value - Urgent, Please help...
>Date: Sat, 10 May 2003 20:47:16 +0200
>
>I am reposting this in the hope of getting a small answer to my problem
>here. I am trying to put a mask var-value containing Unicode characters
>but no luck. The client-side generated code works fine, but the
>server-side does not, and after looking more carefully, I saw that after
>all it calls the Perl5Util.match("\\u05d0", text) instead of just
>"\u05d0" - and therefore it fails. What can I do? Please help...
>
>Here is part of my validation.xml file -
>
><form	name="signupForm">
>			<field	property="user.firstName"
>					depends="required, mask"
>					page="1">
>					<arg0 key="userInfo.firstName"/>
>					<var>
>
><var-name>mask</var-name>
>
><var-value>^[\u05d0-\u05fa]*$</var-value>
>					</var>
>			</field>
>		</form>
>
>
>
>Best regards,
>
>Erez
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online  
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Unicode characters in mask var value - Urgent, Please help...

Posted by Jason Lea <ja...@kumachan.net.nz>.
Hi Erez,

Erez Efrati wrote:
> Thanks for replying Jason,
> 
> Yes that was exactly what I've done an hour ago or so. I got it to work
> but still I need to cover some areas like XML in relation to Unicode.
> Anyway, what I have found is, and maybe it is only me the newbie here,
> but it turns out that only when I wrote the following, it started
> working.
> 
> 	<var-name>mask</var-name>
> 	<var-value>^[&#x05d0;-&#x05ea;]*$</var-value> 

Ahh, yes.  That is the HTML/XML escape sequence.  When the XML file is 
parsed the &#x05d0 is changed into a Unicode character.  The \uXXXX is 
the format that the Java compiler uses (and is used in .properties files).

> using the notation \u05d0... does not work, since the XML parser reads
> it literally, sad but true.
> 
> Having solved that one, I am still not sure why is it so important to
> have the <?xml version="1.0" encoding="UTF-8" ?> line. 

The choice is yours.  If you want to work with and store the actual 
Unicode characters in XML you will need to use the 'UTF-8' encoding.
Otherwise you will need to use the &#xXXXX; where ever you want a 
Unicode character.


> Also, I didn't understand why saving the validation.xml in UTF-8 using
> the notepad doesn't work. The Parser raises an error...just don't know.

If you were still using <?xml version="1.0" encoding="ISO-8859-1" ?> 
encoding it would fail as ISO-8859-1 (Latin1) only specifies the first 
255 characters only.  If you changed to <?xml version="1.0" 
encoding="UTF-8" ?> and saved it I would have thought it would work.

> 
> Anyway thanks for the reply.
> 
> -- Erez

-- 
Jason Lea


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Unicode characters in mask var value - Urgent, Please help...

Posted by Erez Efrati <er...@netmedia.net.il>.
Thanks for replying Jason,

Yes that was exactly what I've done an hour ago or so. I got it to work
but still I need to cover some areas like XML in relation to Unicode.
Anyway, what I have found is, and maybe it is only me the newbie here,
but it turns out that only when I wrote the following, it started
working.

	<var-name>mask</var-name>
	<var-value>^[&#x05d0;-&#x05ea;]*$</var-value> 

using the notation \u05d0... does not work, since the XML parser reads
it literally, sad but true.

Having solved that one, I am still not sure why is it so important to
have the <?xml version="1.0" encoding="UTF-8" ?> line. 

Also, I didn't understand why saving the validation.xml in UTF-8 using
the notepad doesn't work. The Parser raises an error...just don't know.

Anyway thanks for the reply.

-- Erez


-----Original Message-----
From: Jason Lea [mailto:jason@kumachan.net.nz] 
Sent: Sunday, May 11, 2003 12:06 AM
To: Struts Users Mailing List
Subject: Re: Unicode characters in mask var value - Urgent, Please
help...

Hi Erez,

I haven't used validation yet, however I have just done a quick test 
with tiles .xml files.

XML supports Unicode as long as the encoding is specified...

Try changing
	<?xml version="1.0" encoding="ISO-8859-1"?>
into
	<?xml version="1.0" encoding="UTF-8" ?>

Then you can put the actual Unicode character into the .xml file.

-- 
Jason Lea


Erez Efrati wrote:
> David, 
> 
> Yes, you are correct, that what I was trying to say, that it tries to
> match it literally. I tried to type just \u05d0-\u0dfa (I mean no
double
> \) but no luck. The client-side javascript works fine, while the
server
> side get to match the literal string. I also tried to imitate after
the
> initializor parser and I saw that it actually the SAX parser which
reads
> it badly and passes the validator the literal string instead of the
> Unicode characters. I also tried to put it inside a ![CDATA[ block
like
> this..
> 
> 			<field	property="user.firstName"
> 					depends="required, mask"
> 					page="1">
> 					<arg0 key="userInfo.firstName"/>
> 					<var>
> 	
> <var-name>mask</var-name>
> 						<var-value><![CDATA[
> 	
> "^[\u05d0-\u05ea]*$"
> 							]]>
> 						</var-value>
> 					</var>
> 			</field>
> 
> but the SAX is reading it badly again.
> 
> What to do??



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Unicode characters in mask var value - Urgent, Please help...

Posted by Jason Lea <ja...@kumachan.net.nz>.
Hi Erez,

I haven't used validation yet, however I have just done a quick test 
with tiles .xml files.

XML supports Unicode as long as the encoding is specified...

Try changing
	<?xml version="1.0" encoding="ISO-8859-1"?>
into
	<?xml version="1.0" encoding="UTF-8" ?>

Then you can put the actual Unicode character into the .xml file.

-- 
Jason Lea


Erez Efrati wrote:
> David, 
> 
> Yes, you are correct, that what I was trying to say, that it tries to
> match it literally. I tried to type just \u05d0-\u0dfa (I mean no double
> \) but no luck. The client-side javascript works fine, while the server
> side get to match the literal string. I also tried to imitate after the
> initializor parser and I saw that it actually the SAX parser which reads
> it badly and passes the validator the literal string instead of the
> Unicode characters. I also tried to put it inside a ![CDATA[ block like
> this..
> 
> 			<field	property="user.firstName"
> 					depends="required, mask"
> 					page="1">
> 					<arg0 key="userInfo.firstName"/>
> 					<var>
> 	
> <var-name>mask</var-name>
> 						<var-value><![CDATA[
> 	
> "^[\u05d0-\u05ea]*$"
> 							]]>
> 						</var-value>
> 					</var>
> 			</field>
> 
> but the SAX is reading it badly again.
> 
> What to do??



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Unicode characters in mask var value - Urgent, Please help...

Posted by Erez Efrati <er...@netmedia.net.il>.
David, 

Yes, you are correct, that what I was trying to say, that it tries to
match it literally. I tried to type just \u05d0-\u0dfa (I mean no double
\) but no luck. The client-side javascript works fine, while the server
side get to match the literal string. I also tried to imitate after the
initializor parser and I saw that it actually the SAX parser which reads
it badly and passes the validator the literal string instead of the
Unicode characters. I also tried to put it inside a ![CDATA[ block like
this..

			<field	property="user.firstName"
					depends="required, mask"
					page="1">
					<arg0 key="userInfo.firstName"/>
					<var>
	
<var-name>mask</var-name>
						<var-value><![CDATA[
	
"^[\u05d0-\u05ea]*$"
							]]>
						</var-value>
					</var>
			</field>

but the SAX is reading it badly again.

What to do??

-- Erez

-----Original Message-----
From: David Graham [mailto:dgraham1980@hotmail.com] 
Sent: Saturday, May 10, 2003 8:12 PM
To: struts-user@jakarta.apache.org
Subject: Re: Unicode characters in mask var value - Urgent, Please
help...

I think the match is correct because it has to escape the \ you used to 
designate the unicode character.  It's more likely that the validator is

trying to match the literal string \u05d0 instead of whatever character 
that's supposed to represent.  Try typing in \u05d0 and see if you pass 
validation to verify this.

David


>From: Erez Efrati <er...@netmedia.net.il>
>Reply-To: "Struts Users Mailing List" <st...@jakarta.apache.org>
>To: 'Struts Users Mailing List' <st...@jakarta.apache.org>
>Subject: Unicode characters in mask var value - Urgent, Please help...
>Date: Sat, 10 May 2003 20:47:16 +0200
>
>I am reposting this in the hope of getting a small answer to my problem
>here. I am trying to put a mask var-value containing Unicode characters
>but no luck. The client-side generated code works fine, but the
>server-side does not, and after looking more carefully, I saw that
after
>all it calls the Perl5Util.match("\\u05d0", text) instead of just
>"\u05d0" - and therefore it fails. What can I do? Please help...
>
>Here is part of my validation.xml file -
>
><form	name="signupForm">
>			<field	property="user.firstName"
>					depends="required, mask"
>					page="1">
>					<arg0 key="userInfo.firstName"/>
>					<var>
>
><var-name>mask</var-name>
>
><var-value>^[\u05d0-\u05fa]*$</var-value>
>					</var>
>			</field>
>		</form>
>
>
>
>Best regards,
>
>Erez
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online  
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org