Changeset 7634


Ignore:
Timestamp:
2004-06-23T15:26:19+12:00 (20 years ago)
Author:
mdewsnip
Message:

Removed crappy old stripNL function which made a mess of Unicode strings.

File:
1 edited

Legend:

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

    r7620 r7634  
    892892
    893893
    894     /** Method to strip new lines and extra spaces from a string. Used to restore text that has been mangled into width formatted blocks by the DOM parser.
    895      * @param raw_str The <strong>Strong</strong> containing the mangled text.
    896      * @return A <strong>String</strong> with new lines and extra spaces removed.
    897      * @deprecated This function makes a mess of Unicode strings.
    898      */
    899     static public String oldStripNL(String raw_str) {
    900     byte raw[] = raw_str.getBytes();
    901     byte formatted[] = new byte[raw.length];
    902     byte previous = '\0';
    903     int j = 0;
    904     for(int i = 0; i < raw.length; i++) {
    905         if(raw[i] == '\n') {
    906         // Skip new lines.
    907         }
    908         else if(raw[i] == '\t') {
    909         // Skip tabs.
    910         }
    911         else if(raw[i] == ' ' && raw[i] == previous) {
    912         // Skip erroneous whitespace.
    913         }
    914         else {
    915         formatted[j] = raw[i];
    916         j++;
    917         }
    918         previous = raw[i];
    919     }
    920     byte finish[] = new byte[j];
    921     System.arraycopy(formatted, 0, finish, 0, j);
    922     return new String(finish);
    923     }
    924 
    925 
    926     /** I hope this works a bit better on Unicode strings, but I haven't tested it yet! */
     894    /** I think this works a bit better on Unicode strings. */
    927895    static public String stripNL(String raw_string)
    928896    {
Note: See TracChangeset for help on using the changeset viewer.