Changeset 4802 in josm


Ignore:
Timestamp:
Jan 16, 2012 7:00:24 PM (17 months ago)
Author:
simon04
Message:

see #7271 - reuse existing UTFInputStreamReader for handling BOM from GetCapabilities response

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/AddWMSLayerPanel.java

    r4801 r4802  
    1818import java.io.IOException; 
    1919import java.io.InputStream; 
    20 import java.io.InputStreamReader; 
    2120import java.io.StringReader; 
    2221import java.net.MalformedURLException; 
     
    6059import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser; 
    6160import org.openstreetmap.josm.gui.layer.TMSLayer; 
     61import org.openstreetmap.josm.io.UTFInputStreamReader; 
    6262import org.openstreetmap.josm.tools.GBC; 
    6363import org.w3c.dom.Document; 
     
    344344            URLConnection openConnection = getCapabilitiesUrl.openConnection(); 
    345345            InputStream inputStream = openConnection.getInputStream(); 
    346             BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); 
     346            BufferedReader br = new BufferedReader(UTFInputStreamReader.create(inputStream, "UTF-8")); 
    347347            String line; 
    348348            StringBuilder ba = new StringBuilder(); 
    349             boolean isFirstLine = true; 
    350349            while ((line = br.readLine()) != null) { 
    351                 // fix #7271 
    352                 // see http://www.rgagnon.com/javadetails/java-handle-utf8-file-with-bom.html 
    353                 final String UTF8_BOM = "\uFEFF"; 
    354                 if (isFirstLine && line.startsWith(UTF8_BOM)) { 
    355                     System.out.println("Removing UTF8_BOM (0xFEFF) from GetCapabilities response"); 
    356                     line = line.substring(1); 
    357                     isFirstLine = false; 
    358                 } 
    359350                ba.append(line); 
    360351                ba.append("\n"); 
Note: See TracChangeset for help on using the changeset viewer.