Markus Winter wrote:
if I have a text file created on a Mac, drop it into my project, and put it
into an editfield with
EditField1.text = MacFile
then it displays correctly in RB2007R3 it seems MacRoman is used as the
default encoding.
Could be -- I wouldn't recommend depending on that, however. You should
instead always do something like:
EditField1.text = DefineEncoding( MacFile, Encodings.MacRoman )
(or whatever encoding it actually is).
Does anyone know the exact nature of the change and when it happened? I
presume that now UTF8 is used as the default encoding, and not the system
one?
Could be -- but I wouldn't recommend depending on that, either. It
might change. :)
Dim enc as TextEncoding
s = Macfile
enc=s.Encoding
Exception err as NilObjectException
MsgBox err.message
Although enc is Nil no error is raised and no MsgBox is being displayed.
Why would it? A NilObjectException is raised when you do something with
(i.e. dereference) a nil object. Although enc is nil, you haven't tried
to do anything with it.
If I however test with
if enc = Nil then
MsgBox "No encoding defined"
else
MsgBox enc.internetName
end if
then I get the message box. What is the difference here?
Here, you're actually testing whether it is nil.
But note that the whole code snippet you posted is pointless -- you've
read a file, which assigns the encoding value passed to ReadAll (which
defaults to UTF-8 if you don't specify otherwise) to the string. You
then stuff this into enc. This tells you nothing except the default
value of that parameter, which is in the LR. In particular, it does NOT
tell you the actual encoding of the file. Nothing can do that (in general).
Best,
- Joe
--
Joe Strout
Inspiring Applications, Inc.
http://www.InspiringApps.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|