use LINEBR
diff --git a/src/main/java/org/yaml/snakeyaml/emitter/Emitter.java b/src/main/java/org/yaml/snakeyaml/emitter/Emitter.java
index eed8799..e0d0b71 100644
--- a/src/main/java/org/yaml/snakeyaml/emitter/Emitter.java
+++ b/src/main/java/org/yaml/snakeyaml/emitter/Emitter.java
@@ -44,6 +44,7 @@
import org.yaml.snakeyaml.events.StreamEndEvent;
import org.yaml.snakeyaml.events.StreamStartEvent;
import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.reader.Reader;
import org.yaml.snakeyaml.util.ArrayStack;
/**
@@ -958,7 +959,7 @@
}
}
// Check for line breaks, special, and unicode characters.
- if (ch == '\n' || ch == '\u0085' || ch == '\u2028' || ch == '\u2029') {
+ if (Reader.LINEBR.indexOf(ch) != -1) {
lineBreaks = true;
}
if (!(ch == '\n' || ('\u0020' <= ch && ch <= '\u007E'))) {
@@ -985,7 +986,7 @@
}
previousSpace = true;
previousBreak = false;
- } else if ("\n\u0085\u2028\u2029".indexOf(ch) != -1) {
+ } else if (Reader.LINEBR.indexOf(ch) != -1) {
if (index == 0) {
leadingBreak = true;
}
@@ -1004,8 +1005,8 @@
// Prepare for the next character.
index++;
- preceededByWhitespace = "\0 \t\r\n\u0085\u2028\u2029".indexOf(ch) != -1;
- followedByWhitespace = (index + 1 >= scalar.length() || "\0 \t\r\n\u0085\u2028\u2029"
+ preceededByWhitespace = ("\0 \t\r" + Reader.LINEBR).indexOf(ch) != -1;
+ followedByWhitespace = (index + 1 >= scalar.length() || ("\0 \t\r" + Reader.LINEBR)
.indexOf(scalar.charAt(index + 1)) != -1);
}
// Let's decide what styles are allowed.
@@ -1147,7 +1148,7 @@
start = end;
}
} else if (breaks) {
- if (ch == 0 || "\n\u0085\u2028\u2029".indexOf(ch) == -1) {
+ if (ch == 0 || Reader.LINEBR.indexOf(ch) == -1) {
if (text.charAt(start) == '\n') {
writeLineBreak(null);
}
@@ -1163,7 +1164,7 @@
start = end;
}
} else {
- if (ch == 0 || " \n\u0085\u2028\u2029".indexOf(ch) != -1 || ch == '\'') {
+ if (ch == 0 || (" " + Reader.LINEBR).indexOf(ch) != -1 || ch == '\'') {
if (start < end) {
String data = text.substring(start, end);
this.column += data.length();
@@ -1180,7 +1181,7 @@
}
if (ch != 0) {
spaces = ch == ' ';
- breaks = "\n\u0085\u2028\u2029".indexOf(ch) != -1;
+ breaks = Reader.LINEBR.indexOf(ch) != -1;
}
end++;
}
@@ -1250,14 +1251,14 @@
private String determineBlockHints(String text) {
StringBuffer hints = new StringBuffer();
if (text != null && text.length() > 0) {
- if (" \n\u0085\u2028\u2029".indexOf(text.charAt(0)) != -1) {
+ if ((" " + Reader.LINEBR).indexOf(text.charAt(0)) != -1) {
hints.append(bestIndent);
}
char ch1 = text.charAt(text.length() - 1);
- if ("\n\u0085\u2028\u2029".indexOf(ch1) == -1) {
+ if (Reader.LINEBR.indexOf(ch1) == -1) {
hints.append("-");
} else if (text.length() == 1
- || ("\n\u0085\u2028\u2029".indexOf(text.charAt(text.length() - 2)) != -1)) {
+ || (Reader.LINEBR.indexOf(text.charAt(text.length() - 2)) != -1)) {
hints.append("+");
}
}
@@ -1281,7 +1282,7 @@
ch = text.charAt(end);
}
if (breaks) {
- if (ch == 0 || ("\n\0085\u2028\u2029".indexOf(ch) == -1)) {
+ if (ch == 0 || (Reader.LINEBR.indexOf(ch) == -1)) {
if (!leadingSpace && ch != 0 && ch != ' ' && text.charAt(start) == '\n') {
writeLineBreak(null);
}
@@ -1311,7 +1312,7 @@
start = end;
}
} else {
- if (ch == 0 || " \n\0085\u2028\u2029".indexOf(ch) != -1) {
+ if (ch == 0 || (" " + Reader.LINEBR).indexOf(ch) != -1) {
String data = text.substring(start, end);
this.column += data.length();
stream.write(data);
@@ -1322,7 +1323,7 @@
}
}
if (ch != 0) {
- breaks = ("\n\u0085\u2028\u2029".indexOf(ch) != -1);
+ breaks = (Reader.LINEBR.indexOf(ch) != -1);
spaces = (ch == ' ');
}
end++;
@@ -1344,7 +1345,7 @@
ch = text.charAt(end);
}
if (breaks) {
- if (ch == 0 || "\n\u0085\u2028\u2029".indexOf(ch) == -1) {
+ if (ch == 0 || Reader.LINEBR.indexOf(ch) == -1) {
String data = text.substring(start, end);
for (char br : data.toCharArray()) {
if (br == '\n') {
@@ -1359,7 +1360,7 @@
start = end;
}
} else {
- if (ch == 0 || "\n\u0085\u2028\u2029".indexOf(ch) != -1) {
+ if (ch == 0 || Reader.LINEBR.indexOf(ch) != -1) {
String data = text.substring(start, end);
stream.write(data);
if (ch == 0) {
@@ -1369,7 +1370,7 @@
}
}
if (ch != 0) {
- breaks = ("\n\u0085\u2028\u2029".indexOf(ch) != -1);
+ breaks = (Reader.LINEBR.indexOf(ch) != -1);
}
end++;
}
@@ -1411,7 +1412,7 @@
start = end;
}
} else if (breaks) {
- if ("\n\u0085\u2028\u2029".indexOf(ch) == -1) {
+ if (Reader.LINEBR.indexOf(ch) == -1) {
if (text.charAt(start) == '\n') {
writeLineBreak(null);
}
@@ -1429,7 +1430,7 @@
start = end;
}
} else {
- if (ch == 0 || "\n\u0085\u2028\u2029".indexOf(ch) != -1) {
+ if (ch == 0 || Reader.LINEBR.indexOf(ch) != -1) {
String data = text.substring(start, end);
this.column += data.length();
stream.write(data);
@@ -1438,7 +1439,7 @@
}
if (ch != 0) {
spaces = (ch == ' ');
- breaks = ("\n\u0085\u2028\u2029".indexOf(ch) != -1);
+ breaks = (Reader.LINEBR.indexOf(ch) != -1);
}
end++;
}
diff --git a/src/main/java/org/yaml/snakeyaml/reader/Reader.java b/src/main/java/org/yaml/snakeyaml/reader/Reader.java
index 3c960b5..27dcf63 100644
--- a/src/main/java/org/yaml/snakeyaml/reader/Reader.java
+++ b/src/main/java/org/yaml/snakeyaml/reader/Reader.java
@@ -34,7 +34,7 @@
// it in case of data corruption
final static Pattern NON_PRINTABLE = Pattern
.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
- private final static String LINEBR = "\n\u0085\u2028\u2029";
+ public final static String LINEBR = "\n\u0085\u2028\u2029";
private String name;
private final java.io.Reader stream;
diff --git a/src/main/java/org/yaml/snakeyaml/scanner/ScannerImpl.java b/src/main/java/org/yaml/snakeyaml/scanner/ScannerImpl.java
index 878f38e..0d517ea 100644
--- a/src/main/java/org/yaml/snakeyaml/scanner/ScannerImpl.java
+++ b/src/main/java/org/yaml/snakeyaml/scanner/ScannerImpl.java
@@ -27,6 +27,7 @@
import org.yaml.snakeyaml.error.Mark;
import org.yaml.snakeyaml.error.YAMLException;
+import org.yaml.snakeyaml.reader.Reader;
import org.yaml.snakeyaml.tokens.AliasToken;
import org.yaml.snakeyaml.tokens.AnchorToken;
import org.yaml.snakeyaml.tokens.BlockEndToken;
@@ -80,10 +81,10 @@
* @see <a href="http://pyyaml.org/wiki/PyYAML">PyYAML</a> for more information
*/
public final class ScannerImpl implements Scanner {
- private final static String NULL_BL_LINEBR = "\0 \r\n\u0085\u2028\u2029";
- private final static String NULL_BL_T_LINEBR = "\0 \t\r\n\u0085\u2028\u2029";
- public final static String NULL_OR_LINEBR = "\0\r\n\u0085\u2028\u2029";
- private final static String FULL_LINEBR = "\r\n\u0085\u2028\u2029";
+ private final static String NULL_BL_LINEBR = "\0 \r" + Reader.LINEBR;
+ private final static String NULL_BL_T_LINEBR = "\0 \t\r" + Reader.LINEBR;
+ public final static String NULL_OR_LINEBR = "\0\r" + Reader.LINEBR;
+ private final static String FULL_LINEBR = "\r" + Reader.LINEBR;
private final static String ALPHA = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
private final static Pattern NOT_HEXA = Pattern.compile("[^0-9A-Fa-f]");
public final static Map<Character, String> ESCAPE_REPLACEMENTS = new HashMap<Character, String>();
@@ -880,7 +881,7 @@
return reader.getColumn() == 0;
}
- private static final String SPACES = "\0 \t\r\n\u0085\u2028\u2029";
+ private static final String SPACES = "\0 \t\r" + Reader.LINEBR;
private boolean checkDocumentStart() {
// DOCUMENT-START: ^ '---' (' '|'\n')
@@ -945,7 +946,7 @@
* </pre>
*/
char ch = reader.peek();
- return ("\0 \t\r\n\u0085\u2028\u2029-?:,[]{}#&*!|>\'\"%@`".indexOf(ch) == -1 || ("\0 \t\r\n\u0085\u2028\u2029"
+ return (("\0 \t\r-?:,[]{}#&*!|>\'\"%@`" + Reader.LINEBR).indexOf(ch) == -1 || (("\0 \t\r" + Reader.LINEBR)
.indexOf(reader.peek(1)) == -1 && (ch == '-' || (this.flowLevel == 0 && "?:"
.indexOf(ch) != -1))));
}
@@ -983,7 +984,7 @@
reader.forward();
}
if (reader.peek() == '#') {
- while ("\0\r\n\u0085\u2028\u2029".indexOf(reader.peek()) == -1) {
+ while (("\0\r" + Reader.LINEBR).indexOf(reader.peek()) == -1) {
reader.forward();
}
}
@@ -1012,7 +1013,7 @@
endMark = reader.getMark();
} else {
endMark = reader.getMark();
- while ("\0\r\n\u0085\u2028\u2029".indexOf(reader.peek()) == -1) {
+ while (("\0\r" + Reader.LINEBR).indexOf(reader.peek()) == -1) {
reader.forward();
}
}
@@ -1172,7 +1173,7 @@
String value = reader.prefix(length);
reader.forward(length);
ch = reader.peek();
- if ("\0 \t\r\n\u0085\u2028\u2029?:,]}%@`".indexOf(ch) == -1) {
+ if (("\0 \t\r?:,]}%@`" + Reader.LINEBR).indexOf(ch) == -1) {
throw new ScannerException("while scanning an " + name, startMark,
"expected alphabetic or numeric character, but found " + ch + "("
+ ((int) reader.peek()) + ")", reader.getMark());
@@ -1208,7 +1209,7 @@
} else {
int length = 1;
boolean useHandle = false;
- while ("\0 \r\n\u0085\u2028\u2029".indexOf(ch) == -1) {
+ while (("\0 \r" + Reader.LINEBR).indexOf(ch) == -1) {
if (ch == '!') {
useHandle = true;
break;
@@ -1392,7 +1393,7 @@
StringBuffer chunks = new StringBuffer();
int maxIndent = 0;
Mark endMark = reader.getMark();
- while (" \r\n\u0085\u2028\u2029".indexOf(reader.peek()) != -1) {
+ while ((" \r" + Reader.LINEBR).indexOf(reader.peek()) != -1) {
if (reader.peek() != ' ') {
chunks.append(scanLineBreak());
endMark = reader.getMark();
@@ -1459,7 +1460,7 @@
StringBuffer chunks = new StringBuffer();
while (true) {
int length = 0;
- while ("\'\"\\\0 \t\r\n\u0085\u2028\u2029".indexOf(reader.peek(length)) == -1) {
+ while (("\'\"\\\0 \t\r" + Reader.LINEBR).indexOf(reader.peek(length)) == -1) {
length++;
}
if (length != 0) {
@@ -1580,8 +1581,8 @@
}
while (true) {
ch = reader.peek(length);
- if ("\0 \t\r\n\u0085\u2028\u2029".indexOf(ch) != -1
- || (this.flowLevel == 0 && ch == ':' && "\0 \t\r\n\u0085\u2028\u2029"
+ if (("\0 \t\r" + Reader.LINEBR).indexOf(ch) != -1
+ || (this.flowLevel == 0 && ch == ':' && ("\0 \t\r" + Reader.LINEBR)
.indexOf(reader.peek(length + 1)) != -1)
|| (this.flowLevel != 0 && ",:?[]{}".indexOf(ch) != -1)) {
break;
@@ -1590,7 +1591,7 @@
}
// It's not clear what we should do with ':' in the flow context.
if (this.flowLevel != 0 && ch == ':'
- && "\0 \t\r\n\u0085\u2028\u2029,[]{}".indexOf(reader.peek(length + 1)) == -1) {
+ && ("\0 \t\r,[]{}" + Reader.LINEBR).indexOf(reader.peek(length + 1)) == -1) {
reader.forward(length);
throw new ScannerException("while scanning a plain scalar", startMark,
"found unexpected ':'", reader.getMark(),
@@ -1638,7 +1639,7 @@
return "";
}
StringBuffer breaks = new StringBuffer();
- while (" \r\n\u0085\u2028\u2029".indexOf(reader.peek()) != -1) {
+ while ((" \r" + Reader.LINEBR).indexOf(reader.peek()) != -1) {
if (reader.peek() == ' ') {
reader.forward();
} else {