Jump to content
Changes to the Jaspersoft community edition download ×

How to get unicode from data?


Recommended Posts

By: Eric Tan - neltan

How to get unicode from data?

2002-12-02 01:59

Hi,

Chinese in PDF is ok when hardcode something like "u9700".

However, when data in Chinese character can't display correctly.

Here is my xml. Would you please tell what's wrong with that?

 

XML Header set to

<?xml version="1.0" encoding="ISO-8859-1" ?>

Field text which show Chinese is here

<textElement textAlignment="Left" lineSpacing="Single">

<font fontName="kaiu.ttf" pdfFontName="kaiu.ttf" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String">$F{name}</textFieldExpression>

 

 

 

----------------------------------------------------------

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!-- Created with iReport - A designer for JasperReports -->

<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

<jasperReport

name="Chinese"

columnCount="1"

printOrder="Vertical"

orientation="Portrait"

pageWidth="595"

pageHeight="842"

columnWidth="535"

columnSpacing="0"

leftMargin="30"

rightMargin="30"

topMargin="20"

bottomMargin="20"

whenNoDataType="NoPages"

isTitleNewPage="false"

isSummaryNewPage="false">

<queryString><![CDATA[

select * from table1

]]></queryString>

<field name="id" class="java.lang.Integer"/>

<field name="name" class="java.lang.String"/>

<variable name="test" class="java.lang.String" resetType="None" calculation="Nothing">

<variableExpression>"test"</variableExpression>

<initialValueExpression>"test" </initialValueExpression>

</variable>

<title>

<band height="50">

<staticText>

<reportElement

mode="Transparent"

x="61"

y="5"

width="412"

height="40"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Center" lineSpacing="Single">

<font fontName="Times-Roman" pdfFontName="Times-Roman" size="30" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<text><![CDATA[Classic Report Template]]></text>

</staticText>

<line direction="TopDown">

<reportElement

mode="Opaque"

x="0"

y="48"

width="534"

height="0"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<graphicElement stretchType="NoStretch" pen="2Point" fill="Solid" />

</line>

<line direction="TopDown">

<reportElement

mode="Opaque"

x="0"

y="3"

width="534"

height="0"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<graphicElement stretchType="NoStretch" pen="2Point" fill="Solid" />

</line>

</band>

</title>

<pageHeader>

<band height="9">

</band>

</pageHeader>

<columnHeader>

<band height="0">

<line direction="BottomUp">

<reportElement

mode="Opaque"

x="0"

y="0"

width="535"

height="0"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" />

</line>

</band>

</columnHeader>

<detail>

<band height="46">

<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="127"

y="2"

width="398"

height="15"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" lineSpacing="Single">

<font fontName="" pdfFontName="Times-Roman" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.Integer">$F{id}</textFieldExpression>

</textField>

<staticText>

<reportElement

mode="Transparent"

x="0"

y="2"

width="127"

height="15"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" lineSpacing="Single">

<font fontName="" pdfFontName="Times-Bold" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" />

</textElement>

<text><![CDATA[id]]></text>

</staticText>

<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="127"

y="19"

width="398"

height="15"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" lineSpacing="Single">

<font fontName="kaiu.ttf" pdfFontName="kaiu.ttf" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String">$F{name}</textFieldExpression>

</textField>

<staticText>

<reportElement

mode="Transparent"

x="0"

y="19"

width="127"

height="15"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" lineSpacing="Single">

<font fontName="" pdfFontName="Times-Bold" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" />

</textElement>

<text><![CDATA[name]]></text>

</staticText>

</band>

</detail>

<columnFooter>

<band height="0">

</band>

</columnFooter>

<pageFooter>

<band height="27">

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="325"

y="4"

width="174"

height="19"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Right" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String">"Page " + $V{PAGE_NUMBER} + " of "</textFieldExpression>

</textField>

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None" > <reportElement

mode="Transparent"

x="499"

y="4"

width="36"

height="19"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String">"" + $V{PAGE_NUMBER}</textFieldExpression>

</textField>

<line direction="TopDown">

<reportElement

mode="Opaque"

x="1"

y="3"

width="535"

height="0"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<graphicElement stretchType="NoStretch" pen="2Point" fill="Solid" />

</line>

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="1"

y="6"

width="209"

height="19"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" lineSpacing="Single">

<font fontName="Times-Roman" pdfFontName="Times-Roman" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.util.Date">new Date()</textFieldExpression>

</textField>

</band>

</pageFooter>

<summary>

<band height="0">

</band>

</summary>

</jasperReport>

 

 

By: Eric Tan - neltan

RE: How to get unicode from data?

2002-12-02 02:01

Somebody said this can solve.

But I don't know how to "getByte" in the XML.

Can this code get the unicode from data source??

 

String lastName1 = request.getParameter("lastname");

String firstName,lastName;

lastName = new String(lastName1.getBytes("8859_1"),"GBK");

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...