Preferences API . Capitalization anomaly.

P

ptg_abhishek

hello.
i tried the Preferences API provided by JDK2 [1.4.2]. It appears that
each upper case letter written into the windows registry by the API is
preceded by a '/' character.
Has anyone else noticed this behaviour? What is the reason for this?

regards,
abhishek
 
C

Chris Uppal

i tried the Preferences API provided by JDK2 [1.4.2]. It appears that
each upper case letter written into the windows registry by the API is
preceded by a '/' character.
Has anyone else noticed this behaviour? What is the reason for this?

Probably in order to implement case-sensitive key matching when the Windows
registry itself is case-insensitive.

You may find the comment from the relevant method interesting, but I presume
that you should not rely on the details remaining constant:

===========
* Converts value's or node's name to its Windows representation
* as a byte-encoded string.
* Two encodings, simple and altBase64 are used.
* <p>
* <i>Simple</i> encoding is used, if java string does not contain
* any characters less, than 0x0020, or greater, than 0x007f.
* Simple encoding adds "/" character to capital letters, i.e.
* "A" is encoded as "/A". Character '\' is encoded as '//',
* '/' is encoded as '\'.
* The constructed string is converted to byte array by truncating the
* highest byte and adding the terminating <tt>null</tt> character.
* <p>
* <i>altBase64</i> encoding is used, if java string does contain at least
* one character less, than 0x0020, or greater, than 0x007f.
* This encoding is marked by setting first two bytes of the
* Windows string to '/!'. The java name is then encoded using
* byteArrayToAltBase64() method from
* Base64 class.

===========

The Base64.byteArrayToAltBase64() method it refers to is from another
Sun-private class. It appears to do roughly the same thing as "normal" Base64
encoding, but using a different set of encoded characters in order to avoid
uppercase letters.

-- chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top