The text output by FirmaSAT on the Windows console is UTF-8 encoded. This will display "funny" characters on the default console. The text below should read "Juanito Pérez Niño", but the accented characters é and ñ each appear as two funny characters.
To fix, you need to do two things:
Similarly when using Java on the Windows console, you need to change the active code page to 1252 - see Java on the command line below.
The default encoding for Java on the Windows console is typically Cp1252.
You can check by examining the file.encoding
property:
System.out.println("file.encoding=" + System.getProperty("file.encoding"));On our system this displays
file.encoding=Cp1252
To display the output from a Java program correctly in the console follow the instructions above except type chcp 1252 in step 6.
`FirmasatAttribute.java` is a simple Java program to read an attribute from a CFDi XML file. This is equivalent to the FirmaSAT command-line example above.
/* FirmasatAttribute.java */ import net.cryptosys.firmasat.*; public class FirmasatAttribute { public static void main(String[] args) { System.out.println("file.encoding=" + System.getProperty("file.encoding")); String fname = "venta11.xml"; String elementName = "Receptor"; String attributeName = "nombre"; String s = Sat.getXmlAttribute(fname, attributeName, elementName); System.out.println("Sat.getXmlAttribute('"+ fname +"',"+ elementName + "/@" + attributeName +")=\n"+ s ); } }
The image below shows the result of running this Java program with the default code page 850 (funny characters in the output) and after changing the code page to 1252 by typing chcp 1252 (characters appear correctly).
(The font in the above image is Consolas size 16 Bold)
For more information about using Java with FirmaSAT, see the Java Interface to FirmaSAT page.
To comment on this page, or for further information, please send us a message.
This page last updated 12 August 2020