Java Question SLC unmappeable character

DonManfred

Expert
Licensed User
Longtime User
Starting step: Compiling Java code.
Completed successfully.
Starting step: Creating jar file.
Completed successfully.
Starting step: Creating XML file.
C:\Users\Mannes\workspace\MaskFormatter\src\com\azimolabs\maskformatter\CharTransforms.java:66: error: unmappable character for encoding Cp1252
transformMap.put('Z', new TransformPattern("[A-ZÇÀ�ÂÃÈÉÊẼÌ�ÎĨÒÓÔÕÙÚÛŨ]", true, false));
^
C:\Users\Mannes\workspace\MaskFormatter\src\com\azimolabs\maskformatter\CharTransforms.java:66: error: unmappable character for encoding Cp1252
transformMap.put('Z', new TransformPattern("[A-ZÇÀ�ÂÃÈÉÊẼÌ�ÎĨÒÓÔÕÙÚÛŨ]", true, false));
^
C:\Users\Mannes\workspace\MaskFormatter\src\com\azimolabs\maskformatter\CharTransforms.java:70: error: unmappable character for encoding Cp1252
transformMap.put('#', new TransformPattern("[a-zA-Zçáà ãâéèêẽÃìĩîóòôõúùũüûÇÀÃ?ÂÃÈÉÊẼÌÃ?ÎĨÒÓÔÕÙÚÛŨ]", false, false));
^
C:\Users\Mannes\workspace\MaskFormatter\src\com\azimolabs\maskformatter\CharTransforms.java:70: error: unmappable character for encoding Cp1252
transformMap.put('#', new TransformPattern("[a-zA-Zçáà ãâéèêẽÃìĩîóòôõúùũüûÇÀÃ?ÂÃÈÉÊẼÌÃ?ÎĨÒÓÔÕÙÚÛŨ]", false, false));
^

Error.

The Source is encoded as UTF-8
The content is

transformMap.put('Z', new TransformPattern("[A-ZÇÀÁÂÃÈÉÊẼÌÍÎĨÒÓÔÕÙÚÛŨ]", true, false));
transformMap.put('z', new TransformPattern("[a-zçáàãâéèêẽíìĩîóòôõúùũüû]", false, true));

transformMap.put('@', new TransformPattern("[a-zA-Z]", false, false));
transformMap.put('#', new TransformPattern("[a-zA-ZçáàãâéèêẽíìĩîóòôõúùũüûÇÀÁÂÃÈÉÊẼÌÍÎĨÒÓÔÕÙÚÛŨ]", false, false));

But when i compile with SLC it is changed to the above (only for slc. if i open the file in eclipse or even Notepad++ i see the correct characters.

Usually when i get such errors when developing a wrap they are chinese comments in the source. I delete them then and then i can compile the lib.

But in this case i need to let the code as it is not a comment

What can i do to bring slc to compile this library?

Or: where is my problem? Any hints highly welcome
 

DonManfred

Expert
Licensed User
Longtime User
Try to convert the encoding to CP1252 in Eclipse (Edit - Set Encoding).
Today i encountered a similar issue. This time with german umlauts.
Changing the Encoding in Eclipse does not help. SLC still give this error
Simple Library Compiler
Starting step: Compiling Java code.
javac 1.8.0_73
E:\EclipseWorkspace.b4alibs\srw\src\de\donmanfred\RTFDocumentWrapper.java:47: error: unmappable character for encoding UTF-8
// Dokumenteninformation hinzuf?gen
^
1 error


Error.


B4X:
package de.donmanfred;

import java.io.File;
import java.io.IOException;

import com.itseasy.rtf.RTFDocument;
import com.itseasy.rtf.text.Border;
import com.itseasy.rtf.text.Field;
import com.itseasy.rtf.text.Font;
import com.itseasy.rtf.text.InfoGroup;
import com.itseasy.rtf.text.List;
import com.itseasy.rtf.text.NewPage;
import com.itseasy.rtf.text.Paragraph;
import com.itseasy.rtf.text.Tabulator;
import com.itseasy.rtf.text.TextPart;

import anywheresoftware.b4a.AbsObjectWrapper;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.DesignerProperties;
import anywheresoftware.b4a.BA.Property;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;

@Version(1.00f)
@ShortName("RTFDocument")
@Author(value = "DonManfred (wrapper)")
//@Permissions(values={"android.permission.INTERNET", "android.permission.ACCESS_NETWORK_STATE"})
//@Events(values={"onSigned(sign As Object)"})
@DependsOn(values={"srw"})
@DesignerProperties(values = {
        @Property(key="Checked", displayName="Checked", defaultValue="False", fieldType="Boolean")
    })
public class RTFDocumentWrapper extends AbsObjectWrapper<RTFDocument>{
    private BA ba;
    private String filename;

    public void Initialize(final BA ba, String filename) {
        this.filename = filename;
        this.ba = ba;

        final RTFDocument _obj = new RTFDocument();
        setObject(_obj);
        //this.getObject()
       
    // Dokumenteninformation hinzufügen
        this.getObject().getInfo().setInfoAsString(InfoGroup.INFO_AUTHOR, "IT'S EASY");
        this.getObject().getInfo().setInfoAsString(InfoGroup.INFO_TITLE, "Dies ist ein RTF Generierungstest...");
    // Kopfzeile hinzufügen (Zentriert, Schriftgröße 16, Rahmen am Boden)
    Paragraph header = new Paragraph(0, 18, 16, Font.ARIAL, new TextPart("Simple RTF Writer Testdokument"));
    header.setAlignment(Paragraph.ALIGN_CENTER);
    header.setBorder(new Border(Border.BORDER_BOTTOM, Border.BORDERTHICKNESS_SINGLE));
    this.getObject().addHeader(header);
    // Fußzeile hinzufügen (Dateiname links, Aktuelles Datum und Seitennummer Rechts)
    Paragraph footer = new Paragraph(12, 0, 8, Font.TIMES_NEW_ROMAN);
    footer.addTabulator(new Tabulator(170, Tabulator.TABKIND_RIGHT));    // Tabulator bei 17 cm definieren
    footer.addText(new TextPart("Datei: "));
    footer.addText(Field.FIELD_FILENAME);
    footer.addText(new TextPart(TextPart.SIGN_TAB + "Datum: "));
    footer.addText(Field.FIELD_CURRENT_DATE);
    footer.addText(TextPart.NEWLINE);
    footer.addText(new TextPart(TextPart.SIGN_TAB + "Seite "));
    footer.addText(Field.FIELD_CURRENT_PAGENO);
    footer.addText(new TextPart(" von "));
    footer.addText(Field.FIELD_TOTAL_PAGES);
    footer.setBorder(new Border(Border.BORDER_TOP, Border.BORDERTHICKNESS_SINGLE));
    this.getObject().addFooter(footer);
    // 1. Absatz hinzufügen - Schriftmöglichkeiten
    Paragraph absatz = new Paragraph(0, 6);
    absatz.addText(new TextPart("Mit dem Simple RTF Writer (SRW) kann man einfache RTF Dokumente erstellen oder RTF Formulare ausfüllen. Der SRW unterstüzt "));
    absatz.addText(new TextPart(TextPart.FORMAT_ITALIC, "kursiv, "));
    absatz.addText(new TextPart(TextPart.FORMAT_UNDERLINE, "unterstrichen, "));
    absatz.addText(new TextPart(TextPart.FORMAT_BOLD,"fett, "));
    absatz.addText(new TextPart(TextPart.FORMAT_OUTLINE, "outline, "));
    absatz.addText(new TextPart(TextPart.FORMAT_SHADOW, "mit Schatten "));
    absatz.addText(new TextPart("oder "));
    absatz.addText(new TextPart(TextPart.FORMAT_ITALIC + TextPart.FORMAT_UNDERLINE + TextPart.FORMAT_SHADOW
            + TextPart.FORMAT_BOLD + TextPart.FORMAT_OUTLINE, "alles zusammen."));
    this.getObject().addParagraph(absatz);
    // 2. Absatz hinzufügen - Aufzählungsliste (Eine Aufzählungsliste ist auch ein Absatz!)
    absatz = new Paragraph(0, 0, new TextPart("Daneben können auch Aufzählungslisten erstellt werden, wie diese:"));
    this.getObject().addParagraph(absatz);
    List listabsatz = new List(3, 6);
    listabsatz.setSpace(1);        // Zwischen den Aufzählungszeilen, soll ein zusätzlicher Punkt Abstand sein
    listabsatz.addText(new TextPart("1. Aufzählung"));
    listabsatz.addText(new TextPart("2. Aufzählung"));
    listabsatz.addText(new TextPart("3. Aufzählung (Funktioniert auch, wenn ein Aufzählungspunkt über mehr als eine Zeile geht...)"));
    listabsatz.addText(new TextPart("4. Aufzählung"));
    this.getObject().addParagraph(listabsatz);
    // 3. Absatz hinzufügen - Tabulatoren
    absatz = new Paragraph(0, 6, new TextPart("Natürlich untersützt der Simple RTF Writer auch Tabulatoren."));
    absatz.addText(TextPart.NEWLINE);
    // Absätze dem 3. Absatz hinzufügen - kann auch erst zum Schluss passieren...; 3 Mal hinzufügen
    absatz.addTabulator(new Tabulator(10, Tabulator.TABKIND_LEFT));        // 1. Tabulator; 1 cm; Ausrichtung: Links
    absatz.addTabulator(new Tabulator(50, Tabulator.TABKIND_CENTER));    // 2. Tabulator; 5 cm; Ausrichtung: Center
    absatz.addTabulator(new Tabulator(100, Tabulator.TABKIND_DECIMAL));    // 3. Tabulator; 10 cm; Ausrichtung: Dezimal
    absatz.addTabulator(new Tabulator(this.getObject().getPageDefinition().getVisibleLineSize(), Tabulator.TABKIND_RIGHT));    // 4. Tabulator; Rechter Rand; Ausrichtung: Rechts
    // Jetzt kommt der Text für den 3. Absatz
    absatz.addText(TextPart.TABULATOR);
    absatz.addText(new TextPart("Links-Tab"));
    absatz.addText(TextPart.TABULATOR);
    absatz.addText(new TextPart("Center-Tab"));
    absatz.addText(TextPart.TABULATOR);
    absatz.addText(new TextPart("Dezimal,Tab"));
    absatz.addText(TextPart.TABULATOR);
    absatz.addText(new TextPart("Rechts-Tab (ganz Rechts)"));
    // Noch zwei Zeilen
    absatz.addText(TextPart.NEWLINE);
    absatz.addText(new TextPart(TextPart.SIGN_TAB + "xxxx" + TextPart.SIGN_TAB + "xxxx" + TextPart.SIGN_TAB + "xxxx,xx" + TextPart.SIGN_TAB + "xxxx"));
    absatz.addText(TextPart.NEWLINE);
    absatz.addText(new TextPart(TextPart.SIGN_TAB + "xxxxxx" + TextPart.SIGN_TAB + "xxxxxx" + TextPart.SIGN_TAB + "xxxxxx,xx" + TextPart.SIGN_TAB + "xxxxxx"));
    this.getObject().addParagraph(absatz);
    // 4. Absatz hinzufügen - Tabulatoren mit Füllzeichen (Punkte)
    absatz = new Paragraph(0, 0);
    absatz.addTabulator(new Tabulator(10, Tabulator.TABKIND_LEFT));        // 1. Tabulator; 1 cm; Ausrichtung: Links
    absatz.addTabulator(new Tabulator(150, Tabulator.TABKIND_RIGHT, Tabulator.TABLEAD_DOTS));    // 2. Tabulator; 15 cm; Ausrichtung: Rechts
    absatz.addText(new TextPart(TextPart.SIGN_TAB + "Zeilenanfang " + TextPart.SIGN_TAB + " Tab mit Punkten"));
    this.getObject().addParagraph(absatz);
    // 5. Absatz hinzufügen - Tabulatoren mit Füllzeichen (Unterstrichen)
    absatz = new Paragraph(0, 6);
    absatz.addTabulator(new Tabulator(10, Tabulator.TABKIND_LEFT));        // 1. Tabulator; 1 cm; Ausrichtung: Links
    absatz.addTabulator(new Tabulator(150, Tabulator.TABKIND_RIGHT, Tabulator.TABLEAD_UNDERLINE));    // 2. Tabulator; 15 cm; Ausrichtung: Rechts
    absatz.addText(new TextPart(TextPart.SIGN_TAB + "Zeilenanfang " + TextPart.SIGN_TAB + " Tab mit Unterstrich"));
    this.getObject().addParagraph(absatz);
    // 6. Absatz - Verschiedene Schrifte aufzeigen
    absatz = new Paragraph(0, 0, new TextPart("Auch verschiedene Schriftarten werden unterstützt:"));
    this.getObject().addParagraph(absatz);
    absatz = new List(0, 6);
    absatz.addText(new TextPart(TextPart.FORMAT_NORMAL, 12, Font.ARIAL, "Schrift 'Arial' in Größe 12"));
    absatz.addText(new TextPart(TextPart.FORMAT_NORMAL, 14, Font.TIMES_NEW_ROMAN, "Schrift 'Times New Roman' in Größe 14"));
    absatz.addText(new TextPart(TextPart.FORMAT_NORMAL, 10, Font.COURIER_NEW, "Schrift 'Courier New' in Größe 10"));
    absatz.addText(new TextPart(TextPart.FORMAT_NORMAL, 8, Font.SYMBOL, "Schrift 'Symbol' in Größe 8"));
    this.getObject().addParagraph(absatz);
    // 7. Absatz mit Seitenvorschub vor dem Absatz
    absatz = new Paragraph(0, 6);
    absatz.setNewPageBefore(true);        // Neue Zeile vor dem Absatz
    absatz.addText(new TextPart("Dieser Absatz wurde so definiert, dass er auf einer neuen Seite beginnt. "));
    this.getObject().addParagraph(absatz);
    // 8. Normaler Absatz, aber davor nochmal ein Seitenvorschub
    this.getObject().addParagraph(new NewPage());
    absatz = new Paragraph(0, 6);
    absatz.addText(new TextPart("Auch dieser Absatz liegt auf einer neuen Seite. Das Objekt NewPage bewirkt ähnliches wie die Absatzformatierung setNewPageBefore."));
    this.getObject().addParagraph(absatz);
    // Dokument speichern
    try {
        File savefile = new File(this.filename);
        this.getObject().save(savefile);
        System.out.println("Neues RTF Dokument erstellt: " + savefile.getAbsolutePath());
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
       
       
    }
   

       
}
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Today i encountered a similar issue. This time with german umlauts.
Changing the Encoding in Eclipse does not help. SLC still give this error
Did you manage to create .doc file with any language other than English ?

I have been trying Russian and Arabic to no avail .
 

peacemaker

Expert
Licensed User
Longtime User
Maybe not that good this library...
If you find any working java-code or java-lib we probably can help to wrap

Thanks. Maybe try to find any for Open Document Format of OpenOffice ? .ODT, i guess.
Users often asks about possibility to save any app result into office format. If MS proprietary format is ... difficult or legally problem - so, open format should be possible ?
 

leitor79

Active Member
Licensed User
Longtime User
Hello,


Same issue here. I attach an image with the error, and I've uploaded the project here: https://www.dropbox.com/s/auix0ayjqpyrvmi/PhoneValidator.rar?dl=1

I've tried with notepad++ the codification thing (I don't have eclipse, I don't know how to use, that's why I use b4a), but it's already in UTF-8 without BOM.

It's my first SLC project, so I take recommendations about what files aren't needed.

Thank you.

sshot-771.png
sshot-772.png
 

leitor79

Active Member
Licensed User
Longtime User
Thanks, Erel. I know so little about Java I didn't realize it was a comment; I thought it was a part of the error description.

Thank you very much, the library was generated, now I will test it.
 
Top