On 10/11/2011 11:20 AM, Hans-Peter Diettrich wrote:
Michael Schnell schrieb:
Why should a function Utf8ToLower be used (or even be defined for normal use) ?

Because it expects and UTF8 argument, and provides an UTF8 result, so that no further conversions are required when used with strings of exactly that encoding.
I don't understand your argument. If ToLower gets a new string that is UTF8 encoded, the result should be a new string that is UTF8 encoded. So why bother. Checking the encoding Word and branching tho the appropriate encoding-aware functionality is a very fast operation.

With dynamically encoded Strings "ToLower" should work for any encoding.

You mean something like this?
  function ToLower(s: RawByteString): RawByteString;
[dunno whether RawByteString is an allowed Result type at all]
In fact I still don't understand the difference between a type called "RawByteString"and a basic new String that happens to be set to the encoding "RawByte".

IMO, calling ToLower with a string that is set to the encoding "RawByte" does not make sense and should generate an exception. The user code should set a decent "readable character" encoding before doing something like ToLower (or "+" or comparing with a string that is in a "readable character" encoding), if the string is obtained in a way that did not set such a coding signature.

-Michael
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to