mirror of
https://github.com/plexusorg/toml4j.git
synced 2025-01-01 13:02:37 +00:00
Fixed handling of short-form unicode escapes
This commit is contained in:
parent
1380c72d48
commit
ba84494583
3 changed files with 26 additions and 1 deletions
|
@ -1,5 +1,8 @@
|
||||||
# toml4j Changelog
|
# toml4j Changelog
|
||||||
|
|
||||||
|
## NEXT
|
||||||
|
* Fixed short-form Unicode escapes
|
||||||
|
|
||||||
## 0.3.1 / 2014-12-16
|
## 0.3.1 / 2014-12-16
|
||||||
* Support for [TOML 0.3.1](https://github.com/toml-lang/toml/tree/v0.3.1) spec
|
* Support for [TOML 0.3.1](https://github.com/toml-lang/toml/tree/v0.3.1) spec
|
||||||
* Pass TOML validator (https://github.com/BurntSushi/toml-test), which uncovered many bugs.
|
* Pass TOML validator (https://github.com/BurntSushi/toml-test), which uncovered many bugs.
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.util.regex.Pattern;
|
||||||
class StringConverter implements ValueConverter {
|
class StringConverter implements ValueConverter {
|
||||||
|
|
||||||
static final StringConverter STRING_PARSER = new StringConverter();
|
static final StringConverter STRING_PARSER = new StringConverter();
|
||||||
private static final Pattern UNICODE_REGEX = Pattern.compile("\\\\[uU](.*)");
|
private static final Pattern UNICODE_REGEX = Pattern.compile("\\\\[uU](.{4})");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConvert(String s) {
|
public boolean canConvert(String s) {
|
||||||
|
|
22
src/test/java/com/moandjiezana/toml/UnicodeTest.java
Normal file
22
src/test/java/com/moandjiezana/toml/UnicodeTest.java
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package com.moandjiezana.toml;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class UnicodeTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void should_support_short_escape_form() throws Exception {
|
||||||
|
Toml toml = new Toml().parse("key = \"Jos\u00E9\\nLocation\tSF\"");
|
||||||
|
|
||||||
|
assertEquals("José\nLocation\tSF", toml.getString("key"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void should_support_unicode_literal() throws Exception {
|
||||||
|
Toml toml = new Toml().parse("key = \"José LöcÄtion SF\"");
|
||||||
|
|
||||||
|
assertEquals("José LöcÄtion SF", toml.getString("key"));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue