Changeset 30285 in osm for applications/editors/josm/plugins/smed2/src/s57/S57dat.java
- Timestamp:
- 2014-02-17T14:27:01+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/s57/S57dat.java
r30284 r30285 1 /* Copyright 2014 Malcolm Herring 2 * 3 * This is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, version 3 of the License. 6 * 7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>. 8 */ 9 1 10 package s57; 2 11 12 import java.io.UnsupportedEncodingException; 3 13 import java.util.ArrayList; 4 14 import java.util.Arrays; … … 165 175 private static int index; 166 176 private static S57field field; 177 private static String aall = "US-ASCII"; 178 private static String nall = "US-ASCII"; 167 179 public static int rnum; 168 180 … … 219 231 if (conv.bin == 0) { 220 232 String str = ""; 233 int i = 0; 221 234 if (conv.asc == 0) { 222 while (buffer[offset] != 0x1f) { 223 str += (char)(buffer[offset++]); 224 } 225 offset++; 235 for (i=0; buffer[offset+i] != 0x1f; i++) {} 236 try { 237 String charset = ""; 238 if (field == S57field.ATTF) charset = aall; 239 else if (field == S57field.NATF) charset = nall; 240 else charset = "US-ASCII"; 241 str = new String(buffer, offset, i, charset); 242 } catch (UnsupportedEncodingException e) { 243 e.printStackTrace(); 244 } 245 offset += i + 1; 226 246 } else { 227 247 str = new String(buffer, offset, conv.asc); … … 239 259 } 240 260 offset += Math.abs(conv.bin); 261 if ((subf == S57subf.AALL) || (subf == S57subf.NALL)) { 262 String charset = ""; 263 switch ((int)val) { 264 case 0: 265 charset = "US-ASCII"; 266 break; 267 case 1: 268 charset = "ISO-8859-1"; 269 break; 270 case 2: 271 charset = "UTF-16LE"; 272 break; 273 } 274 if (subf == S57subf.NALL) { 275 nall = charset; 276 } else { 277 aall = charset; 278 } 279 } 241 280 return val; 242 281 } else {
Note:
See TracChangeset
for help on using the changeset viewer.