Mercurial > dive4elements > river
changeset 5714:1103308b19ca
Add toJavaEncodedString function to encode strings in utf-16 notation
used by java. This fixes printing of unicode characters.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 15 Apr 2013 11:34:28 +0200 |
parents | f5d966428703 |
children | 37e4073dc0bb |
files | flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintPanel.java |
diffstat | 1 files changed, 29 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintPanel.java Mon Apr 15 18:27:14 2013 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintPanel.java Mon Apr 15 11:34:28 2013 +0200 @@ -286,6 +286,26 @@ return ""; } + public static String toJavaEncodedString(String str) { + if (str == null) { + return null; + } + StringBuilder sb = new StringBuilder(); + for (int i = 0, len = str.length(); i < len; i++) { + int unipoint = Character.codePointAt(str, i); + if ((unipoint < 32) || (unipoint > 127)) { + sb.append("\\u"); + sb.append(Integer.toHexString((unipoint >> 3*4) & 0xf)); + sb.append(Integer.toHexString((unipoint >> 2*4) & 0xf)); + sb.append(Integer.toHexString((unipoint >> 1*4) & 0xf)); + sb.append(Integer.toHexString((unipoint >> 0*4) & 0xf)); + } else { + sb.append(str.charAt(i)); + } + } + return sb.toString(); + } + protected void updateCollection() { final Config config = Config.getInstance(); final String loc = config.getLocale(); @@ -293,15 +313,15 @@ GWT.log("MapPrintPanel.updateCollection via RPC now"); List<Property> properties = new ArrayList<Property>(); - properties.add(new PropertySetting(MAPFISH_MAPTITLE, this.pageTitle.getValueAsString())); -// properties.add(new PropertySetting(MAPFISH_LAYOUT, this.pageFormat.getValueAsString())); - properties.add(new PropertySetting(MAPFISH_SUBTITLE, this.pageSubtitle.getValueAsString())); - properties.add(new PropertySetting(MAPFISH_RANGE, this.pageRange.getValueAsString())); - properties.add(new PropertySetting(MAPFISH_STRETCH, this.pageStrech.getValueAsString())); - properties.add(new PropertySetting(MAPFISH_CREATED, this.pageCreated.getValueAsString())); - properties.add(new PropertySetting(MAPFISH_SOURCE, this.pageSource.getValueAsString())); - properties.add(new PropertySetting(MAPFISH_CREATOR, this.pageCreator.getValueAsString())); - properties.add(new PropertySetting(MAPFISH_DATEPLACE, this.pageDatePlace.getValueAsString())); + properties.add(new PropertySetting(MAPFISH_MAPTITLE, toJavaEncodedString(pageTitle.getValueAsString()))); +// properties.add(new PropertySetting(MAPFISH_LAYOUT, toJavaEncodedString(pageFormat.getValueAsString()))); + properties.add(new PropertySetting(MAPFISH_SUBTITLE, toJavaEncodedString(pageSubtitle.getValueAsString()))); + properties.add(new PropertySetting(MAPFISH_RANGE, toJavaEncodedString(pageRange.getValueAsString()))); + properties.add(new PropertySetting(MAPFISH_STRETCH, toJavaEncodedString(pageStrech.getValueAsString()))); + properties.add(new PropertySetting(MAPFISH_CREATED, toJavaEncodedString(pageCreated.getValueAsString()))); + properties.add(new PropertySetting(MAPFISH_SOURCE, toJavaEncodedString(pageSource.getValueAsString()))); + properties.add(new PropertySetting(MAPFISH_CREATOR, toJavaEncodedString(pageCreator.getValueAsString()))); + properties.add(new PropertySetting(MAPFISH_DATEPLACE, toJavaEncodedString(pageDatePlace.getValueAsString()))); settings.setSettings("default", properties); collection.addSettings("print-settings", settings);