Search in sources :

Example 1 with Utf8Writer

use of ezvcard.util.Utf8Writer in project ez-vcard by mangstadt.

the class JCardReaderTest method utf8.

@Test
public void utf8() throws Throwable {
    // @formatter:off
    String json = "[\"vcard\"," + "[" + "[\"version\", {}, \"text\", \"4.0\"]," + "[\"note\", {}, \"text\", \"\u019dote\"]" + "]" + "]";
    File file = tempFolder.newFile();
    Writer writer = new Utf8Writer(file);
    writer.write(json);
    writer.close();
    JCardReader reader = new JCardReader(file);
    VCardAsserter asserter = new VCardAsserter(reader);
    asserter.next(V4_0);
    asserter.simpleProperty(Note.class).value("\u019dote").noMore();
    asserter.done();
// @formatter:on
}
Also used : Utf8Writer(ezvcard.util.Utf8Writer) VCardAsserter(ezvcard.property.asserter.VCardAsserter) File(java.io.File) Writer(java.io.Writer) Utf8Writer(ezvcard.util.Utf8Writer) Test(org.junit.Test)

Example 2 with Utf8Writer

use of ezvcard.util.Utf8Writer in project ez-vcard by mangstadt.

the class XCardReaderTest method read_utf8.

@Test
public void read_utf8() throws Exception {
    // @formatter:off
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<vcards xmlns=\"" + V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<note><text>\u019dote</text></note>" + "</vcard>" + "</vcards>";
    File file = tempFolder.newFile();
    Writer writer = new Utf8Writer(file);
    writer.write(xml);
    writer.close();
    XCardReader reader = new XCardReader(file);
    VCardAsserter asserter = new VCardAsserter(reader);
    asserter.next(V4_0);
    asserter.simpleProperty(Note.class).value("\u019dote").noMore();
    asserter.done();
// @formatter:on
}
Also used : Utf8Writer(ezvcard.util.Utf8Writer) VCardAsserter(ezvcard.property.asserter.VCardAsserter) File(java.io.File) Writer(java.io.Writer) Utf8Writer(ezvcard.util.Utf8Writer) Test(org.junit.Test)

Aggregations

VCardAsserter (ezvcard.property.asserter.VCardAsserter)2 Utf8Writer (ezvcard.util.Utf8Writer)2 File (java.io.File)2 Writer (java.io.Writer)2 Test (org.junit.Test)2