tmiller 02/03/28 08:18:38
Modified: java/src/org/apache/xalan/xsltc/runtime TextOutput.java
Log:
bug fix for output31, output32 tests, esc chars
Revision Changes Path
1.52 +21 -5
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TextOutput.java
Index: TextOutput.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TextOutput.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- TextOutput.java 19 Mar 2002 20:37:57 -0000 1.51
+++ TextOutput.java 28 Mar 2002 16:18:38 -0000 1.52
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: TextOutput.java,v 1.51 2002/03/19 20:37:57 tmiller Exp $
+ * @(#)$Id: TextOutput.java,v 1.52 2002/03/28 16:18:38 tmiller Exp $
*
* The Apache Software License, Version 1.1
*
@@ -127,7 +127,7 @@
private static final String EMPTYSTRING = "";
private static final String HREF_STR = "href";
private static final String CITE_STR = "cite";
- private static final String SRC_STR = "str";
+ private static final String SRC_STR = "src";
private static final String CHAR_ESC_START = "&#";
private static final String CDATA_ESC_START = "]]>&#";
private static final String CDATA_ESC_END = ";<![CDATA[";
@@ -671,6 +671,14 @@
return(buf.toString());
}
+ private String makeHHString(int i) {
+ String s = Integer.toHexString(i).toUpperCase();
+ if (s.length() == 1) {
+ s = "0"+s;
+ }
+ return s;
+ }
+
/**
* This method escapes special characters used in HTML attribute values
*/
@@ -682,9 +690,17 @@
char[] ch = base.toCharArray();
StringBuffer buf = new StringBuffer();
for(int i=0; i<base.length(); i++){
- if (ch[i] > '\u007F') {
- buf.append('%');
- buf.append(Integer.toHexString((int)ch[i]));
+ if (ch[i] <= 0x20) {
+ buf.append('%');
+ buf.append(makeHHString(ch[i]));
+ }
+ else if (ch[i] > '\u007F') {
+ int high = (ch[i] >> 6) | 0xC0;
+ int low = (ch[i] & 0x3F) | 0x80; // First 6 bits + high bit
+ buf.append('%');
+ buf.append(makeHHString(high));
+ buf.append('%');
+ buf.append(makeHHString(low));
}
else {
// These chars are reserved or unsafe in URLs
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]