Ignore:
Timestamp:
2014-02-17T14:27:01+01:00 (11 years ago)
Author:
malcolmh
Message:

save

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
    110package s57;
    211
     12import java.io.UnsupportedEncodingException;
    313import java.util.ArrayList;
    414import java.util.Arrays;
     
    165175        private static int index;
    166176        private static S57field field;
     177        private static String aall = "US-ASCII";
     178        private static String nall = "US-ASCII";
    167179        public static int rnum;
    168180       
     
    219231                if (conv.bin == 0) {
    220232                        String str = "";
     233                        int i = 0;
    221234                        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;
    226246                        } else {
    227247                                str = new String(buffer, offset, conv.asc);
     
    239259                                }
    240260                                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                                }
    241280                                return val;
    242281                        } else {
Note: See TracChangeset for help on using the changeset viewer.