Changeset 16952 in josm


Ignore:
Timestamp:
2020-08-28T22:38:26+02:00 (4 weeks ago)
Author:
simon04
Message:

see #19717 - Extract DefaultNameFormatter.removeBiDiCharacters

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DefaultNameFormatter.java

    r16951 r16952  
    672672        return formatAsHtmlUnorderedList(Collections.singletonList(primitive), 1);
    673673    }
     674
     675    /**
     676     * Removes the bidirectional text characters U+200C, U+200E, U+200F from the string
     677     * @param string the string
     678     * @return the string with the bidirectional text characters removed
     679     */
     680    public static String removeBiDiCharacters(String string) {
     681        return string.replaceAll("[\\u200C\\u200E\\u200F]", "");
     682    }
    674683}
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/PrimitiveTransferable.java

    r16951 r16952  
    99import java.util.List;
    1010
     11import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
    1112import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1213import org.openstreetmap.josm.data.osm.PrimitiveData;
     
    9192            sb.append(OsmPrimitiveType.from(primitive).getAPIName()).append(' ').append(primitive.getId());
    9293        }
    93         return sb.toString().replace("\u200C", "").replace("\u200E", "").replace("\u200F", "");
     94        return DefaultNameFormatter.removeBiDiCharacters(sb.toString());
    9495    }
    9596}
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/RelationMemberTransferable.java

    r16951 r16952  
    107107              .append('\n');
    108108        }
    109         return sb.toString().replace("\u200C", "").replace("\u200E", "").replace("\u200F", "");
     109        return DefaultNameFormatter.removeBiDiCharacters(sb.toString());
    110110    }
    111111
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DefaultNameFormatterTest.java

    r16951 r16952  
    168168                        TestUtils.newNode("tourism=hotel name:en=foo url=http://foo.bar xml=<tag/>")));
    169169    }
     170
     171    /**
     172     * Test of {@link DefaultNameFormatter#removeBiDiCharacters(String)}.
     173     */
     174    @Test
     175    public void testRemoveBiDiCharacters() {
     176        assertEquals("building (0 nodes)", DefaultNameFormatter.removeBiDiCharacters("\u200Ebuilding\u200E (0 nodes)\u200C"));
     177    }
    170178}
Note: See TracChangeset for help on using the changeset viewer.