Changeset 33994 for main


Ignore:
Timestamp:
2020-03-03T14:42:14+13:00 (4 years ago)
Author:
davidb
Message:

The introduction of UTF8Control class means we can now work directly with resource-bundle/property files and assume they deliver UTF-8 strings to the Java code; this class is based on a StackOverflow posting; additional comments to how we then use this in Greenstone (relating to the 'initial' string) noted in Dictionary.java

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/Dictionary.java

    r33769 r33994  
    6262        try
    6363        {
    64             this.raw = ResourceBundle.getBundle(this.resource, this.locale);
     64            this.raw = ResourceBundle.getBundle(this.resource, this.locale, new UTF8Control());
    6565        }
    6666        catch (Exception e)
     
    7676        try
    7777        {
    78             this.raw = ResourceBundle.getBundle(this.resource, this.locale);
     78            this.raw = ResourceBundle.getBundle(this.resource, this.locale, new UTF8Control());
    7979        }
    8080        catch (Exception e)
     
    103103            try
    104104            {
    105             this.raw = ResourceBundle.getBundle(this.resource, this.locale, loader);
     105            this.raw = ResourceBundle.getBundle(this.resource, this.locale, loader, new UTF8Control());
    106106            return;
    107107            }
     
    114114        try
    115115        {
    116             this.raw = ResourceBundle.getBundle(this.resource, this.locale);
     116            this.raw = ResourceBundle.getBundle(this.resource, this.locale, new UTF8Control());
    117117        }
    118118        catch (Exception ex)
     
    220220        try
    221221        {
    222             String initial_raw = this.raw.getString(key);
    223             // convert to unicode, copied from gatherer dictionary
    224             String initial = new String(initial_raw.getBytes("ISO-8859-1"), "UTF-8");
     222                // In older versions of Java, the resource-bundle/properties file was assumed to be "ISO-8859-1", and so
     223            // we used to perform a string conversion here so we could support UTF-8
     224            // With the introduction of UTF8Control, based on a StackOverflow posting, we now directly work
     225            // with the resource as UTF-8, and so not conversion is needed
     226            String initial = this.raw.getString(key);
    225227
    226228            // if we haven't been given any args, don't bother looking for them
Note: See TracChangeset for help on using the changeset viewer.