#1 2018-01-22 14:20:14

field_bus
Member
Registered: 2018-01-22

Unicode Text in Jasper's StaticText

Hello,

Unicode text incorrectly displayed in Jasper Report using StaticText element, I can see '???' symbols. But Unicode text (from MSQL) successfully displayed using Jasper's TextField element.

(ReportServer RS3.0.3-6002, Win 10 Pro 64-bit, MSQL Express 2017).

JRXML file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.5.1.final using JasperReports Library version 6.5.1  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="JReport1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isFloatColumnFooter="true" uuid="824e6be0-0464-47df-bb43-b3b5f35c40f4">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="SQLDataAdapter.xml"/>
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <queryString>
        <![CDATA[SELECT *
FROM "Table_1"]]>
    </queryString>
    <field name="field1" class="java.lang.String">
        <property name="com.jaspersoft.studio.field.label" value=""/>
    </field>
    <field name="field2" class="java.lang.String">
        <property name="com.jaspersoft.studio.field.label" value=""/>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="54" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band height="67" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="550" height="30" uuid="ba3fb67f-70b9-4d9d-aae1-2290175a3bfa"/>
                <textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
                    <font fontName="DejaVu Sans" size="14" isBold="false"/>
                </textElement>
                <text><![CDATA[Elektroenerģijas patēriņš (kW/h)]]></text>
            </staticText>
        </band>
    </pageHeader>
    <columnHeader>
        <band height="23" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="180" height="22" uuid="a1c3b1b2-9745-468c-89a2-2a33dc0fe53a">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="04ccfc2e-76e2-425b-8d82-ab6aedcc8bd2"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="DejaVu Sans" isBold="true"/>
                    <paragraph lineSpacing="Double"/>
                </textElement>
                <text><![CDATA[Skaitītāji]]></text>
            </staticText>
            <staticText>
                <reportElement x="180" y="0" width="370" height="22" uuid="2c9e539f-de02-4df8-88e4-06ed2e011252">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d0c9d2cb-452a-45be-9c92-0daad8dade13"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="DejaVu Sans" isBold="true"/>
                </textElement>
                <text><![CDATA[Patēriņš]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="20" splitType="Stretch">
            <textField>
                <reportElement x="0" y="-1" width="180" height="20" uuid="893179f8-1ff5-4427-a92c-7ac11ca4c374">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="04ccfc2e-76e2-425b-8d82-ab6aedcc8bd2"/>
                </reportElement>
                <box padding="3">
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font fontName="DejaVu Sans"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{field1}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="180" y="-1" width="370" height="20" uuid="6ca7bab4-87a5-4795-af4f-64fe3aad9096">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d0c9d2cb-452a-45be-9c92-0daad8dade13"/>
                </reportElement>
                <box padding="3">
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font fontName="DejaVu Sans"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{field2}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

Offline

#2 2018-01-23 16:13:00

eduardo
Administrator
Registered: 2016-11-01
Website

Re: Unicode Text in Jasper's StaticText

Hi field_bus,

so if I understand correctly, the *data* is showing correctly, only the static text ("Elektroenerģijas patēriņš (kW/h)", "Skaitītāji", "Patēriņš") is *not* showing correctly?
Have you tried to write the unicode codes directly, as shown here? http://jasperreports.sourceforge.net/sa … index.html

Regards,
Eduardo

Offline

#3 2018-01-24 12:21:21

field_bus
Member
Registered: 2018-01-22

Re: Unicode Text in Jasper's StaticText

Thank you very much for information, but I am not successful yet.

I made "TitleStr" parameter

<parameter name="TitleStr" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["Elektroenerģijas patēriņš (kW/h) āāāāāķķļļ"]]></defaultValueExpression>
</parameter>


and added $P{TitleStr} expression in TextField.

<textField>
    <reportElement x="180" y="18" width="300" height="18" uuid="4a5b2c4d-e258-4613-99e5-061ff1840f59"/>
               <textElement><font fontName="DejaVu Sans"/></textElement>
              <textFieldExpression><![CDATA[$P{TitleStr}]]></textFieldExpression>
</textField>

Offline

#4 2018-01-24 12:55:54

eduardo
Administrator
Registered: 2016-11-01
Website

Re: Unicode Text in Jasper's StaticText

Hi field_bus,

but did you try by inserting the utf-codes, e.g.?:
<defaultValueExpression>
      \u0402 \u040B \u040F \u0414 \u0416 \u0418 \u041B \u0426 \u0429 \u042E
    </defaultValueExpression>

Regards,
Eduardo

Offline

#5 2018-01-26 07:57:44

field_bus
Member
Registered: 2018-01-22

Re: Unicode Text in Jasper's StaticText

Hi edulid,

yes, it's work. Thank you very much.

<defaultValueExpression>
          <![CDATA["Elektroener\u011Fijas pat\u0113ri\u0146\u0161"]]>
</defaultValueExpression>

Offline

Board footer

Powered by FluxBB