[jira] Commented: (VELOCITY-519) Java escape sequences should work in Velocity macros

2007-02-26 Thread Christoph Reck (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-519?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12475835
 ] 

Christoph Reck commented on VELOCITY-519:
-

If inserting  automatic translation of unicode characters work, the template 
writer might predefine and use $tab, $CR, $LF constants instead of \t, \r \n 
thus keeping BC.

#set( $tab = \u0009 )
...
#if( $samplestring.contains($tab) ) 

P.S. in the past I used the UrlDecoder to achieve this.

 Java escape sequences should work in Velocity macros
 

 Key: VELOCITY-519
 URL: https://issues.apache.org/jira/browse/VELOCITY-519
 Project: Velocity
  Issue Type: New Feature
Affects Versions: 1.5 beta2
Reporter: Stepan Koltsov
 Fix For: 1.6

 Attachments: velocity-unescape-2007-02-24-stepancheg.diff, 
 velocity-unescape-only-u-2007-02-24-stepancheg.diff


 Following test should work:
 ===
 public void testJavaEscape() throws Exception {
 VelocityEngine ve = new VelocityEngine();
 ve.init();
 Context context = new VelocityContext();
 StringWriter writer = new StringWriter();
 ve.evaluate(context, writer, test,#set($v = \\\u0061\)$v);
 assertEquals(a, writer.toString());
 writer = new StringWriter();
 ve.evaluate(context, writer, test,#set($v = \\\n\)$v);
 assertEquals(\n, writer.toString());
 }
 ===

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[jira] Commented: (VELOCITY-519) Java escape sequences should work in Velocity macros

2007-02-26 Thread Nathan Bubna (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-519?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12475897
 ] 

Nathan Bubna commented on VELOCITY-519:
---

The only consensus here is that we should fix the lexer error when \u 
appears in a string definition.  This would be Stepan's second attached patch.

And yes, this will allow you to insert tabs, carriage returns and line feeds by 
typing *six* characters for each instead of just typing the one tab, CR or LF 
character.   why do:
#set( $tab = \u0009 ) 
which doesn't even work yet, when
#set( $tab =)
already works?

 Java escape sequences should work in Velocity macros
 

 Key: VELOCITY-519
 URL: https://issues.apache.org/jira/browse/VELOCITY-519
 Project: Velocity
  Issue Type: New Feature
Affects Versions: 1.5 beta2
Reporter: Stepan Koltsov
 Fix For: 1.6

 Attachments: velocity-unescape-2007-02-24-stepancheg.diff, 
 velocity-unescape-only-u-2007-02-24-stepancheg.diff


 Following test should work:
 ===
 public void testJavaEscape() throws Exception {
 VelocityEngine ve = new VelocityEngine();
 ve.init();
 Context context = new VelocityContext();
 StringWriter writer = new StringWriter();
 ve.evaluate(context, writer, test,#set($v = \\\u0061\)$v);
 assertEquals(a, writer.toString());
 writer = new StringWriter();
 ve.evaluate(context, writer, test,#set($v = \\\n\)$v);
 assertEquals(\n, writer.toString());
 }
 ===

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[jira] Commented: (VELOCITY-519) Java escape sequences should work in Velocity macros

2007-02-25 Thread Christopher Schultz (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-519?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12475718
 ] 

Christopher Schultz commented on VELOCITY-519:
--

If \u syntax works, then it's still possible to insert newlines (\u000a and 
\u000c) and tabs (\u0009), even if the escape sequences aren't as recognizable.

Another option would be to fix bug VELOCITY-520 such that \u escapes do not 
cause an error any longer, and then create a macro that takes a string and 
converts \u and \r, \n, \t, etc. escape sequences into their actual characters.


 Java escape sequences should work in Velocity macros
 

 Key: VELOCITY-519
 URL: https://issues.apache.org/jira/browse/VELOCITY-519
 Project: Velocity
  Issue Type: New Feature
Affects Versions: 1.5 beta2
Reporter: Stepan Koltsov
 Fix For: 1.6

 Attachments: velocity-unescape-2007-02-24-stepancheg.diff, 
 velocity-unescape-only-u-2007-02-24-stepancheg.diff


 Following test should work:
 ===
 public void testJavaEscape() throws Exception {
 VelocityEngine ve = new VelocityEngine();
 ve.init();
 Context context = new VelocityContext();
 StringWriter writer = new StringWriter();
 ve.evaluate(context, writer, test,#set($v = \\\u0061\)$v);
 assertEquals(a, writer.toString());
 writer = new StringWriter();
 ve.evaluate(context, writer, test,#set($v = \\\n\)$v);
 assertEquals(\n, writer.toString());
 }
 ===

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[jira] Commented: (VELOCITY-519) Java escape sequences should work in Velocity macros

2007-02-24 Thread Will Glass-Husain (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-519?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12475618
 ] 

Will Glass-Husain commented on VELOCITY-519:


That's a good point.  If the \u00b1 format didn't work at all before, there's 
no harm in adding it in.  And it adds new capability.  (inserting characters 
into the body that you might not have been able to before).

But if \t, \r, \n were were just passed through (and possibly this was desired 
by someone generating Java code) we shouldn't intercept it.  So I withdraw my 
suggestion for \t, \r, \n parsing.  

 Java escape sequences should work in Velocity macros
 

 Key: VELOCITY-519
 URL: https://issues.apache.org/jira/browse/VELOCITY-519
 Project: Velocity
  Issue Type: New Feature
Affects Versions: 1.5 beta2
Reporter: Stepan Koltsov
 Attachments: velocity-unescape-2007-02-24-stepancheg.diff, 
 velocity-unescape-only-u-2007-02-24-stepancheg.diff


 Following test should work:
 ===
 public void testJavaEscape() throws Exception {
 VelocityEngine ve = new VelocityEngine();
 ve.init();
 Context context = new VelocityContext();
 StringWriter writer = new StringWriter();
 ve.evaluate(context, writer, test,#set($v = \\\u0061\)$v);
 assertEquals(a, writer.toString());
 writer = new StringWriter();
 ve.evaluate(context, writer, test,#set($v = \\\n\)$v);
 assertEquals(\n, writer.toString());
 }
 ===

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[jira] Commented: (VELOCITY-519) Java escape sequences should work in Velocity macros

2007-02-23 Thread Christopher Schultz (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-519?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12475562
 ] 

Christopher Schultz commented on VELOCITY-519:
--

Stepan,
The only reason that Java needs unicode escaping in source files is because 
java source files are defined to be ISO-8859-1. You simply cannot put higher 
characters like Kanji into a Java source file, hence the \u1234 escape 
sequences. Same thing with properties files.

Velocity template files have no such restrictions IIRC. Why not simply use 
UTF-8 encoding and put your special characters directly into your template 
files? There's really no need for escaping of these kinds of things.

Now, newline escaping is another story, unless there is a non '\n' (or '\r') 
newline character that I don't know about.


 Java escape sequences should work in Velocity macros
 

 Key: VELOCITY-519
 URL: https://issues.apache.org/jira/browse/VELOCITY-519
 Project: Velocity
  Issue Type: New Feature
Affects Versions: 1.5 beta2
Reporter: Stepan Koltsov
 Attachments: velocity-unescape-2007-02-24-stepancheg.diff


 Following test should work:
 ===
 public void testJavaEscape() throws Exception {
 VelocityEngine ve = new VelocityEngine();
 ve.init();
 Context context = new VelocityContext();
 StringWriter writer = new StringWriter();
 ve.evaluate(context, writer, test,#set($v = \\\u0061\)$v);
 assertEquals(a, writer.toString());
 writer = new StringWriter();
 ve.evaluate(context, writer, test,#set($v = \\\n\)$v);
 assertEquals(\n, writer.toString());
 }
 ===

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[jira] Commented: (VELOCITY-519) Java escape sequences should work in Velocity macros

2007-02-23 Thread Nathan Bubna (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-519?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12475585
 ] 

Nathan Bubna commented on VELOCITY-519:
---

Thanks, i'll let Will take responsibility for the unicode escapes patch if he's 
willing.  If not, i guess i'd be willing to do it since it's better than the 
current bug. :)

As for the line breaks, i don't see why anyone should need them when the can 
just put the actual carriage return or new line right into the string.

 Java escape sequences should work in Velocity macros
 

 Key: VELOCITY-519
 URL: https://issues.apache.org/jira/browse/VELOCITY-519
 Project: Velocity
  Issue Type: New Feature
Affects Versions: 1.5 beta2
Reporter: Stepan Koltsov
 Attachments: velocity-unescape-2007-02-24-stepancheg.diff, 
 velocity-unescape-only-u-2007-02-24-stepancheg.diff


 Following test should work:
 ===
 public void testJavaEscape() throws Exception {
 VelocityEngine ve = new VelocityEngine();
 ve.init();
 Context context = new VelocityContext();
 StringWriter writer = new StringWriter();
 ve.evaluate(context, writer, test,#set($v = \\\u0061\)$v);
 assertEquals(a, writer.toString());
 writer = new StringWriter();
 ve.evaluate(context, writer, test,#set($v = \\\n\)$v);
 assertEquals(\n, writer.toString());
 }
 ===

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[jira] Commented: (VELOCITY-519) Java escape sequences should work in Velocity macros

2007-02-23 Thread Will Glass-Husain (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-519?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12475589
 ] 

Will Glass-Husain commented on VELOCITY-519:


Stepan makes good points (I believe) about the utility of including escaped 
unicode characters.  Actually, I face similar issues from time to time.  My 
main text editor doesn't do a good job with UTF-8.

I advocate \n, \r, and more importantly, \t for comprehensiveness.  If we allow 
unicode escaping then users will expect the other items.   Are there more that 
need to be included?

I can imagine cases where inserting a tab character might be useful.  For 
example, you might want to compare a string to \t in an #if statement.  The 
following

#if($samplestring.contains(\t))

is more readable than

#if($samplestring.contains(\t))

You could do this with a tool, but this is simpler syntax.

WILL


 Java escape sequences should work in Velocity macros
 

 Key: VELOCITY-519
 URL: https://issues.apache.org/jira/browse/VELOCITY-519
 Project: Velocity
  Issue Type: New Feature
Affects Versions: 1.5 beta2
Reporter: Stepan Koltsov
 Attachments: velocity-unescape-2007-02-24-stepancheg.diff, 
 velocity-unescape-only-u-2007-02-24-stepancheg.diff


 Following test should work:
 ===
 public void testJavaEscape() throws Exception {
 VelocityEngine ve = new VelocityEngine();
 ve.init();
 Context context = new VelocityContext();
 StringWriter writer = new StringWriter();
 ve.evaluate(context, writer, test,#set($v = \\\u0061\)$v);
 assertEquals(a, writer.toString());
 writer = new StringWriter();
 ve.evaluate(context, writer, test,#set($v = \\\n\)$v);
 assertEquals(\n, writer.toString());
 }
 ===

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[jira] Commented: (VELOCITY-519) Java escape sequences should work in Velocity macros

2007-02-23 Thread Will Glass-Husain (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-519?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12475592
 ] 

Will Glass-Husain commented on VELOCITY-519:


Been thinking-- is this backwards compatible?  I'm not sure.

Mostly, it is.  But if a user is generating Java code and expects the escape 
sequences to pass through, then we're in trouble.

Any thoughts?

 Java escape sequences should work in Velocity macros
 

 Key: VELOCITY-519
 URL: https://issues.apache.org/jira/browse/VELOCITY-519
 Project: Velocity
  Issue Type: New Feature
Affects Versions: 1.5 beta2
Reporter: Stepan Koltsov
 Attachments: velocity-unescape-2007-02-24-stepancheg.diff, 
 velocity-unescape-only-u-2007-02-24-stepancheg.diff


 Following test should work:
 ===
 public void testJavaEscape() throws Exception {
 VelocityEngine ve = new VelocityEngine();
 ve.init();
 Context context = new VelocityContext();
 StringWriter writer = new StringWriter();
 ve.evaluate(context, writer, test,#set($v = \\\u0061\)$v);
 assertEquals(a, writer.toString());
 writer = new StringWriter();
 ve.evaluate(context, writer, test,#set($v = \\\n\)$v);
 assertEquals(\n, writer.toString());
 }
 ===

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]