Changeset 6552 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2013-12-28T00:30:15+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 3 edited
-
BugReportExceptionHandler.java (modified) (1 diff)
-
I18n.java (modified) (4 diffs)
-
Utils.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java
r6380 r6552 194 194 ByteArrayOutputStream out = new ByteArrayOutputStream(); 195 195 GZIPOutputStream gzip = new GZIPOutputStream(out); 196 gzip.write(debugText.getBytes( "UTF-8"));196 gzip.write(debugText.getBytes(Utils.UTF_8)); 197 197 Utils.close(gzip); 198 198 -
trunk/src/org/openstreetmap/josm/tools/I18n.java
r6380 r6552 548 548 if(rval != val) /* file corrupt */ 549 549 return false; 550 enstrings[i] = new String(str, 0, val, "utf-8");550 enstrings[i] = new String(str, 0, val, Utils.UTF_8); 551 551 } 552 552 for(int i = 0; i < trnum; ++i) … … 562 562 if(rval != val) /* file corrupt */ 563 563 return false; 564 trstrings[i] = new String(str, 0, val, "utf-8");564 trstrings[i] = new String(str, 0, val, Utils.UTF_8); 565 565 } 566 566 if(trnum > 0 && !p.containsKey(enstrings[0])) { … … 600 600 if(val != enval) /* file corrupt */ 601 601 return false; 602 String enstr = new String(str, 0, enval, "utf-8");602 String enstr = new String(str, 0, enval, Utils.UTF_8); 603 603 if(trval != 0) 604 604 { … … 606 606 if(val != trval) /* file corrupt */ 607 607 return false; 608 String trstr = new String(str, 0, trval, "utf-8");608 String trstr = new String(str, 0, trval, Utils.UTF_8); 609 609 if(!s.containsKey(enstr)) 610 610 s.put(enstr, trstr); -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r6538 r6552 23 23 import java.io.InputStreamReader; 24 24 import java.io.OutputStream; 25 import java.io.UnsupportedEncodingException;26 25 import java.net.HttpURLConnection; 27 26 import java.net.URL; 28 27 import java.net.URLConnection; 29 28 import java.nio.channels.FileChannel; 29 import java.nio.charset.Charset; 30 30 import java.security.MessageDigest; 31 31 import java.security.NoSuchAlgorithmException; … … 56 56 } 57 57 58 /** 59 * UTF-8 (UCS Transformation Format—8-bit). 60 * 61 * <p>Every implementation of the Java platform is required to support UTF-8 (see {@link Charset}).</p> 62 */ 63 public static final Charset UTF_8 = Charset.forName("UTF-8"); 64 58 65 public static <T> boolean exists(Iterable<? extends T> collection, Predicate<? super T> predicate) { 59 66 for (T item : collection) { … … 436 443 */ 437 444 public static String md5Hex(String data) { 438 byte[] byteData = null; 439 try { 440 byteData = data.getBytes("UTF-8"); 441 } catch (UnsupportedEncodingException e) { 442 throw new RuntimeException(); 443 } 445 byte[] byteData = data.getBytes(UTF_8); 444 446 MessageDigest md = null; 445 447 try { … … 707 709 */ 708 710 public static BufferedReader openURLReaderAndDecompress(final URL url, final boolean decompress) throws IOException { 709 return new BufferedReader(new InputStreamReader(openURLAndDecompress(url, decompress), "utf-8"));711 return new BufferedReader(new InputStreamReader(openURLAndDecompress(url, decompress), UTF_8)); 710 712 } 711 713
Note:
See TracChangeset
for help on using the changeset viewer.
