Changeset 7620


Ignore:
Timestamp:
2004-06-18T14:13:28+12:00 (20 years ago)
Author:
mdewsnip
Message:

Quickly hacked up a new stripNL function which will hopefully work OK on Unicode strings... but I haven't tested it yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r7574 r7620  
    897897     * @deprecated This function makes a mess of Unicode strings.
    898898     */
    899     static public String stripNL(String raw_str) {
     899    static public String oldStripNL(String raw_str) {
    900900    byte raw[] = raw_str.getBytes();
    901901    byte formatted[] = new byte[raw.length];
     
    924924
    925925
     926    /** I hope this works a bit better on Unicode strings, but I haven't tested it yet! */
     927    static public String stripNL(String raw_string)
     928    {
     929    String stripped_string = new String();
     930    for (int i = 0; i < raw_string.length(); i++) {
     931        char raw_character = raw_string.charAt(i);
     932        if (raw_character != '\n' && raw_character != '\t') {
     933        stripped_string = stripped_string + raw_character;
     934        }
     935    }
     936    return stripped_string;
     937    }
     938
     939
    926940    static public String trimCenter(String text, int length) {
    927941    if(text.length() > length) {
Note: See TracChangeset for help on using the changeset viewer.