Home All Groups Group Topic Archive Search About

Opentextfile TriStateMixed

Author
8 Dec 2008 6:49 PM
Lou
What does this parameter do?
Set ts = fs.OpenTextFile("MyFile.txt",ForReading, False, TristateMixed)

Can it determine what format the file is and open it accordingly?
Unicode,UTF-8, etc????

-Lou

Author
8 Dec 2008 7:21 PM
mayayana
> What does this parameter do?
> Set ts = fs.OpenTextFile("MyFile.txt",ForReading, False, TristateMixed)
>
> Can it determine what format the file is and open it accordingly?
> Unicode,UTF-8, etc????
>

  You seem to be in the wrong newsgroup. Are you
actually using VBScript? That's not the same as VB.
VBS has it's own group here:

microsoft.public.scripting.vbscript

  You also shouldn't assume that people know what
you're talking about with that code. I'm guessing
that fs is Scripting.FileSystemObject. If you're using
VB it's best to avoid the FileSystemObject. It's slow,
limited, and requires a dependency on scrrun.dll which
may not be installed on all systems.

  As for your question, the options for that OpenTextFile
parameter are ASCII, Unicode, or system default. It's explained
in the help file. If you don't have a copy of the Windows
Script Host help -- which inculdes FileSystemObject -- then
you really should get one. The following is a direct link. The
official link for the WSH help requires that you install Microsoft's
sleazy WGA spyware (and that you be running a Windows
version where that *can* be installed). This link is for
the CHM file itself. (Watch out for wordwrap.)

http://download.microsoft.com/download/9/1/d/91dfd1b3-a274-4e17-a376-f605ff3
9c58c/script56.chm
Author
8 Dec 2008 8:49 PM
Lou
The help file is broken. (Scripts56.chm)

All the data on the right side comes up with
"The address is invalid"

I see the tree view with the contents but nothing gets displayed?


Show quoteHide quote
"mayayana" <mayaXXy***@rcXXn.com> wrote in message
news:%23ZuJCnWWJHA.3912@TK2MSFTNGP06.phx.gbl...
>> What does this parameter do?
>> Set ts = fs.OpenTextFile("MyFile.txt",ForReading, False, TristateMixed)
>>
>> Can it determine what format the file is and open it accordingly?
>> Unicode,UTF-8, etc????
>>
>
>  You seem to be in the wrong newsgroup. Are you
> actually using VBScript? That's not the same as VB.
> VBS has it's own group here:
>
> microsoft.public.scripting.vbscript
>
>  You also shouldn't assume that people know what
> you're talking about with that code. I'm guessing
> that fs is Scripting.FileSystemObject. If you're using
> VB it's best to avoid the FileSystemObject. It's slow,
> limited, and requires a dependency on scrrun.dll which
> may not be installed on all systems.
>
>  As for your question, the options for that OpenTextFile
> parameter are ASCII, Unicode, or system default. It's explained
> in the help file. If you don't have a copy of the Windows
> Script Host help -- which inculdes FileSystemObject -- then
> you really should get one. The following is a direct link. The
> official link for the WSH help requires that you install Microsoft's
> sleazy WGA spyware (and that you be running a Windows
> version where that *can* be installed). This link is for
> the CHM file itself. (Watch out for wordwrap.)
>
> http://download.microsoft.com/download/9/1/d/91dfd1b3-a274-4e17-a376-f605ff3
> 9c58c/script56.chm
>
>
Author
8 Dec 2008 11:57 PM
mayayana
> The help file is broken. (Scripts56.chm)
>
> All the data on the right side comes up with
> "The address is invalid"
>
> I see the tree view with the contents but nothing gets displayed?
>

  That's unfortunate. That problem has come up
before in the scripting group but I don't think
that anyone ever figured out the problem. It
seems to be some kind of bugginess with Microsoft's
HTML help. For awhile I was sticking with the 5.1
version help because v. 5.6 caused constant script
error messages. (Win98SE IE5.00) Somewhere along
the line that got fixed and now the script56.chm file
works fine for me. I just tried the download I linked
and it's OK for me. Sorry I can't be more helpful.
Maybe there's some kind of HTML help update patch
for XP, but I don't know.
Author
8 Dec 2008 7:38 PM
Lou
I am using VB6
This seems to be the right group???


Show quoteHide quote
"mayayana" <mayaXXy***@rcXXn.com> wrote in message
news:%23ZuJCnWWJHA.3912@TK2MSFTNGP06.phx.gbl...
>> What does this parameter do?
>> Set ts = fs.OpenTextFile("MyFile.txt",ForReading, False, TristateMixed)
>>
>> Can it determine what format the file is and open it accordingly?
>> Unicode,UTF-8, etc????
>>
>
>  You seem to be in the wrong newsgroup. Are you
> actually using VBScript? That's not the same as VB.
> VBS has it's own group here:
>
> microsoft.public.scripting.vbscript
>
>  You also shouldn't assume that people know what
> you're talking about with that code. I'm guessing
> that fs is Scripting.FileSystemObject. If you're using
> VB it's best to avoid the FileSystemObject. It's slow,
> limited, and requires a dependency on scrrun.dll which
> may not be installed on all systems.
>
>  As for your question, the options for that OpenTextFile
> parameter are ASCII, Unicode, or system default. It's explained
> in the help file. If you don't have a copy of the Windows
> Script Host help -- which inculdes FileSystemObject -- then
> you really should get one. The following is a direct link. The
> official link for the WSH help requires that you install Microsoft's
> sleazy WGA spyware (and that you be running a Windows
> version where that *can* be installed). This link is for
> the CHM file itself. (Watch out for wordwrap.)
>
> http://download.microsoft.com/download/9/1/d/91dfd1b3-a274-4e17-a376-f605ff3
> 9c58c/script56.chm
>
>
Author
8 Dec 2008 7:58 PM
Bill McCarthy
Hi Lou,

TristateMixed is -2.  It's an old value which is in fact the same as
TristateDefault


Show quoteHide quote
"Lou" <lou.gar***@comcast.net> wrote in message
news:ud5t8WWWJHA.1576@TK2MSFTNGP03.phx.gbl...
> What does this parameter do?
> Set ts = fs.OpenTextFile("MyFile.txt",ForReading, False, TristateMixed)
>
> Can it determine what format the file is and open it accordingly?
> Unicode,UTF-8, etc????
>
> -Lou
>
Author
8 Dec 2008 8:44 PM
Lou
Thanks Everybody but I am still stuck.
I use FTP to grab a file from a server.
After the file is saved locally I need to open the file and convert it to a
Unicode file.
So before I open the file I need to know it's encoding, Unicode,utf-8 or
ascii so I can maintain
the files integrity.

How can I find that out?
At some point I convert everything to Unicode.
VB6 is not good in this area. It's very simple in DotNet but
unfortunately I have to use VB6.

-Lou


Show quoteHide quote
"Bill McCarthy" <B***@localhost.com> wrote in message
news:48429FDA-F0DE-437B-8AA8-5CF2410CC5F9@microsoft.com...
> Hi Lou,
>
> TristateMixed is -2.  It's an old value which is in fact the same as
> TristateDefault
>
>
> "Lou" <lou.gar***@comcast.net> wrote in message
> news:ud5t8WWWJHA.1576@TK2MSFTNGP03.phx.gbl...
>> What does this parameter do?
>> Set ts = fs.OpenTextFile("MyFile.txt",ForReading, False, TristateMixed)
>>
>> Can it determine what format the file is and open it accordingly?
>> Unicode,UTF-8, etc????
>>
>> -Lou
>>
>
Author
8 Dec 2008 8:57 PM
Bill McCarthy
Hi Lou,

Open the file for binary and read the first couple of bytes.  Unicode files
have &HFF &HFE; Ansi don't.


Show quoteHide quote
"Lou" <lou.gar***@comcast.net> wrote in message
news:OnFkFXXWJHA.4488@TK2MSFTNGP04.phx.gbl...
> Thanks Everybody but I am still stuck.
> I use FTP to grab a file from a server.
> After the file is saved locally I need to open the file and convert it to
> a Unicode file.
> So before I open the file I need to know it's encoding, Unicode,utf-8 or
> ascii so I can maintain
> the files integrity.
>
> How can I find that out?
> At some point I convert everything to Unicode.
> VB6 is not good in this area. It's very simple in DotNet but
> unfortunately I have to use VB6.
>
> -Lou
>
>
> "Bill McCarthy" <B***@localhost.com> wrote in message
> news:48429FDA-F0DE-437B-8AA8-5CF2410CC5F9@microsoft.com...
>> Hi Lou,
>>
>> TristateMixed is -2.  It's an old value which is in fact the same as
>> TristateDefault
>>
>>
>> "Lou" <lou.gar***@comcast.net> wrote in message
>> news:ud5t8WWWJHA.1576@TK2MSFTNGP03.phx.gbl...
>>> What does this parameter do?
>>> Set ts = fs.OpenTextFile("MyFile.txt",ForReading, False, TristateMixed)
>>>
>>> Can it determine what format the file is and open it accordingly?
>>> Unicode,UTF-8, etc????
>>>
>>> -Lou
>>>
>>
>
>
Author
9 Dec 2008 3:09 PM
Lou
I figured out if its Unicode but how do I know if it's utf-8 or utf-16?


Show quoteHide quote
"Bill McCarthy" <B***@localhost.com> wrote in message
news:9E133159-2693-4083-8E57-088BF81A0310@microsoft.com...
> Hi Lou,
>
> Open the file for binary and read the first couple of bytes.  Unicode
> files have &HFF &HFE; Ansi don't.
>
>
> "Lou" <lou.gar***@comcast.net> wrote in message
> news:OnFkFXXWJHA.4488@TK2MSFTNGP04.phx.gbl...
>> Thanks Everybody but I am still stuck.
>> I use FTP to grab a file from a server.
>> After the file is saved locally I need to open the file and convert it to
>> a Unicode file.
>> So before I open the file I need to know it's encoding, Unicode,utf-8 or
>> ascii so I can maintain
>> the files integrity.
>>
>> How can I find that out?
>> At some point I convert everything to Unicode.
>> VB6 is not good in this area. It's very simple in DotNet but
>> unfortunately I have to use VB6.
>>
>> -Lou
>>
>>
>> "Bill McCarthy" <B***@localhost.com> wrote in message
>> news:48429FDA-F0DE-437B-8AA8-5CF2410CC5F9@microsoft.com...
>>> Hi Lou,
>>>
>>> TristateMixed is -2.  It's an old value which is in fact the same as
>>> TristateDefault
>>>
>>>
>>> "Lou" <lou.gar***@comcast.net> wrote in message
>>> news:ud5t8WWWJHA.1576@TK2MSFTNGP03.phx.gbl...
>>>> What does this parameter do?
>>>> Set ts = fs.OpenTextFile("MyFile.txt",ForReading, False, TristateMixed)
>>>>
>>>> Can it determine what format the file is and open it accordingly?
>>>> Unicode,UTF-8, etc????
>>>>
>>>> -Lou
>>>>
>>>
>>
>>
>
Author
8 Dec 2008 11:59 PM
Karl E. Peterson
Lou wrote:
> At some point I convert everything to Unicode.
> VB6 is not good in this area. It's very simple in DotNet but
> unfortunately I have to use VB6.

I'm not sure how it could be any simpler?

Perhaps it's your understanding that's too simple?
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
9 Dec 2008 3:10 PM
Lou
Karl, That was not kind.
It truly is a real problem.
-Lou

Show quoteHide quote
"Karl E. Peterson" <k***@mvps.org> wrote in message
news:OapFTEZWJHA.5520@TK2MSFTNGP03.phx.gbl...
> Lou wrote:
>> At some point I convert everything to Unicode.
>> VB6 is not good in this area. It's very simple in DotNet but
>> unfortunately I have to use VB6.
>
> I'm not sure how it could be any simpler?
>
> Perhaps it's your understanding that's too simple?
> --
> .NET: It's About Trust!
> http://vfred.mvps.org
>
Author
9 Dec 2008 4:54 PM
Karl E. Peterson
Lou wrote:
> "Karl E. Peterson" <k***@mvps.org> wrote ...
>> Lou wrote:
>>> At some point I convert everything to Unicode.
>>> VB6 is not good in this area. It's very simple in DotNet but
>>> unfortunately I have to use VB6.
>>
>> I'm not sure how it could be any simpler?
>>
>> Perhaps it's your understanding that's too simple?
>
> Karl, That was not kind.
> It truly is a real problem.

Perhaps you can explain what's so difficult about converting to Unicode with VB6,
then?  Or, at least articulate the problem in such a way that one of us might show
you just how easy it truly is?
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
12 Dec 2008 5:27 AM
Lou
A file is FTP'ed to a local server. The File may be in any given
encoding, it's not always the same. It has many languages etc.
It may have many languages in the same file. I need to figure out the
encoding
so I can convert any of the input files to a standard Unicode utf-16.
So, detecting the file encoding is critical. I can't use strConv because it
takes
a string and as soon as I set any of the files contecnts to a VB string VB
converts it to ANSI
based on the current system code page and the data integrity is loss.
VB's insistance on converting strings to ANSI means
I use byte arrays and can use the ADO stream object to convert and encoding
to any other encoding
but I need to know what that encoding is to begin with.

-Lou

Show quoteHide quote
"Karl E. Peterson" <k***@mvps.org> wrote in message
news:%23EiWe7hWJHA.1532@TK2MSFTNGP03.phx.gbl...
> Lou wrote:
>> "Karl E. Peterson" <k***@mvps.org> wrote ...
>>> Lou wrote:
>>>> At some point I convert everything to Unicode.
>>>> VB6 is not good in this area. It's very simple in DotNet but
>>>> unfortunately I have to use VB6.
>>>
>>> I'm not sure how it could be any simpler?
>>>
>>> Perhaps it's your understanding that's too simple?
>>
>> Karl, That was not kind.
>> It truly is a real problem.
>
> Perhaps you can explain what's so difficult about converting to Unicode
> with VB6, then?  Or, at least articulate the problem in such a way that
> one of us might show you just how easy it truly is?
> --
> .NET: It's About Trust!
> http://vfred.mvps.org
>
Author
12 Dec 2008 6:21 AM
Michael Cole
Lou  <lou.gar***@comcast.net> wrote in message
Show quoteHide quote
<news:%23XCQepBXJHA.5***@TK2MSFTNGP03.phx.gbl>

> A file is FTP'ed to a local server. The File may be in any given
> encoding, it's not always the same. It has many languages etc.
> It may have many languages in the same file. I need to figure out the
> encoding
> so I can convert any of the input files to a standard Unicode utf-16.
> So, detecting the file encoding is critical. I can't use strConv
> because it takes
> a string and as soon as I set any of the files contecnts to a VB
> string VB converts it to ANSI
> based on the current system code page and the data integrity is loss.
> VB's insistance on converting strings to ANSI means
> I use byte arrays and can use the ADO stream object to convert and
> encoding to any other encoding
> but I need to know what that encoding is to begin with.

The only way to know for certain is to get the person who created the file
to tell you.  Otherwise it will be guess work.  There is no fool-proof
method, and the language that you use is irrelivent.

--
Regards

Michael Cole
Author
12 Dec 2008 5:09 PM
Karl E. Peterson
Lou wrote:
Show quoteHide quote
> "Karl E. Peterson" <k***@mvps.org> wrote ...
>> Lou wrote:
>>> "Karl E. Peterson" <k***@mvps.org> wrote ...
>>>> Lou wrote:
>>>>> At some point I convert everything to Unicode.
>>>>> VB6 is not good in this area. It's very simple in DotNet but
>>>>> unfortunately I have to use VB6.
>>>>
>>>> I'm not sure how it could be any simpler?
>>>>
>>>> Perhaps it's your understanding that's too simple?
>>>
>>> Karl, That was not kind.
>>> It truly is a real problem.
>>
>> Perhaps you can explain what's so difficult about converting to Unicode
>> with VB6, then?  Or, at least articulate the problem in such a way that
>> one of us might show you just how easy it truly is?
>
> A file is FTP'ed to a local server. The File may be in any given
> encoding, it's not always the same. It has many languages etc.
> It may have many languages in the same file. I need to figure out the
> encoding
> so I can convert any of the input files to a standard Unicode utf-16.
> So, detecting the file encoding is critical. I can't use strConv because it
> takes
> a string and as soon as I set any of the files contecnts to a VB string VB
> converts it to ANSI
> based on the current system code page and the data integrity is loss.
> VB's insistance on converting strings to ANSI means
> I use byte arrays and can use the ADO stream object to convert and encoding
> to any other encoding
> but I need to know what that encoding is to begin with.

Okay, so what you're saying is that *you* are not very good at converting to and
from Unicode, and are instead choosing to blame the tool you're using and at the
same time making things up about a tool you're not using.  Gotcha.
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
15 Dec 2008 2:43 PM
Lou
What I am saying is no one has issued a solution for this problem and
everyone agreed it is not solvable using VB6 unless I know who wrote the
original file.
If you have a solution put it in words here for the entire group to read.
It's put up or shut up time for you Karl.
My colleagues and I have lost respect for you Karl.
It would help to be more professional. Gives VB6 forum a bad name.

-Lou


Show quoteHide quote
"Karl E. Peterson" <k***@mvps.org> wrote in message
news:eC0szxHXJHA.6000@TK2MSFTNGP05.phx.gbl...
> Lou wrote:
>> "Karl E. Peterson" <k***@mvps.org> wrote ...
>>> Lou wrote:
>>>> "Karl E. Peterson" <k***@mvps.org> wrote ...
>>>>> Lou wrote:
>>>>>> At some point I convert everything to Unicode.
>>>>>> VB6 is not good in this area. It's very simple in DotNet but
>>>>>> unfortunately I have to use VB6.
>>>>>
>>>>> I'm not sure how it could be any simpler?
>>>>>
>>>>> Perhaps it's your understanding that's too simple?
>>>>
>>>> Karl, That was not kind.
>>>> It truly is a real problem.
>>>
>>> Perhaps you can explain what's so difficult about converting to Unicode
>>> with VB6, then?  Or, at least articulate the problem in such a way that
>>> one of us might show you just how easy it truly is?
>>
>> A file is FTP'ed to a local server. The File may be in any given
>> encoding, it's not always the same. It has many languages etc.
>> It may have many languages in the same file. I need to figure out the
>> encoding
>> so I can convert any of the input files to a standard Unicode utf-16.
>> So, detecting the file encoding is critical. I can't use strConv because
>> it
>> takes
>> a string and as soon as I set any of the files contecnts to a VB string
>> VB
>> converts it to ANSI
>> based on the current system code page and the data integrity is loss.
>> VB's insistance on converting strings to ANSI means
>> I use byte arrays and can use the ADO stream object to convert and
>> encoding
>> to any other encoding
>> but I need to know what that encoding is to begin with.
>
> Okay, so what you're saying is that *you* are not very good at converting
> to and from Unicode, and are instead choosing to blame the tool you're
> using and at the same time making things up about a tool you're not using.
> Gotcha.
> --
> .NET: It's About Trust!
> http://vfred.mvps.org
>
Author
16 Dec 2008 1:27 AM
Karl E. Peterson
Lou wrote:
> What I am saying is no one has issued a solution for this problem and
> everyone agreed it is not solvable using VB6 unless I know who wrote the
> original file.

That's *way* different than: "It's very simple in DotNet but..."

It was the preface that I took issue with.  You might as well say:

> What I am saying is no one has issued a solution for this problem and
> everyone agreed it is not solvable unless I know who wrote the original file.

That's just as accurate, although it doesn't make you look like an idiot for
thinking VB6 has any bearing on the situation.  What point is there in adding "using
VB6" to that sentence other than to either a) demonstrate your lack of true
understanding *or* b) inflame others?

> If you have a solution put it in words here for the entire group to read.
> It's put up or shut up time for you Karl.
> My colleagues and I have lost respect for you Karl.
> It would help to be more professional. Gives VB6 forum a bad name.

Get a grip.  Time to regain your perspective, and consider your words more
carefully.  I'll leave both our words fully intact, below, so calmer heads can
decide who's lost it here.
--
..NET: It's About Trust!
http://vfred.mvps.org




Show quoteHide quote
> "Karl E. Peterson" <k***@mvps.org> wrote in message
> news:eC0szxHXJHA.6000@TK2MSFTNGP05.phx.gbl...
>> Lou wrote:
>>> "Karl E. Peterson" <k***@mvps.org> wrote ...
>>>> Lou wrote:
>>>>> "Karl E. Peterson" <k***@mvps.org> wrote ...
>>>>>> Lou wrote:
>>>>>>> At some point I convert everything to Unicode.
>>>>>>> VB6 is not good in this area. It's very simple in DotNet but
>>>>>>> unfortunately I have to use VB6.
>>>>>>
>>>>>> I'm not sure how it could be any simpler?
>>>>>>
>>>>>> Perhaps it's your understanding that's too simple?
>>>>>
>>>>> Karl, That was not kind.
>>>>> It truly is a real problem.
>>>>
>>>> Perhaps you can explain what's so difficult about converting to Unicode
>>>> with VB6, then?  Or, at least articulate the problem in such a way that
>>>> one of us might show you just how easy it truly is?
>>>
>>> A file is FTP'ed to a local server. The File may be in any given
>>> encoding, it's not always the same. It has many languages etc.
>>> It may have many languages in the same file. I need to figure out the
>>> encoding
>>> so I can convert any of the input files to a standard Unicode utf-16.
>>> So, detecting the file encoding is critical. I can't use strConv because
>>> it
>>> takes
>>> a string and as soon as I set any of the files contecnts to a VB string
>>> VB
>>> converts it to ANSI
>>> based on the current system code page and the data integrity is loss.
>>> VB's insistance on converting strings to ANSI means
>>> I use byte arrays and can use the ADO stream object to convert and
>>> encoding
>>> to any other encoding
>>> but I need to know what that encoding is to begin with.
>>
>> Okay, so what you're saying is that *you* are not very good at converting
>> to and from Unicode, and are instead choosing to blame the tool you're
>> using and at the same time making things up about a tool you're not using.
>> Gotcha.
>> --
>> .NET: It's About Trust!
>> http://vfred.mvps.org
Author
16 Dec 2008 9:24 AM
Bill McCarthy
"Karl E. Peterson" <k***@mvps.org> wrote in message
news:eScQG2xXJHA.2372@TK2MSFTNGP03.phx.gbl...
> Lou wrote:
>> What I am saying is no one has issued a solution for this problem and
>> everyone agreed it is not solvable using VB6 unless I know who wrote the
>> original file.
>
> That's *way* different than: "It's very simple in DotNet but..."
>

He spoke the truth.


> It was the preface that I took issue with.


Uh huh.. so we have yet another lengthy rant that actually doesn't help
anyone because **you took issue** with reality.

> You might as well say:
>
>> What I am saying is no one has issued a solution for this problem and
>> everyone agreed it is not solvable unless I know who wrote the original
>> file.
>
> That's just as accurate, although it doesn't make you look like an idiot
> for thinking VB6 has any bearing on the situation.  What point is there in
> adding "using VB6" to that sentence other than to either a) demonstrate
> your lack of true understanding

I think the lack of understanding is on your part.  He stated a simple
honest fact.  you decide to attack because you take issue with that.
If you *understood* what he was talking about with the example of how easy
it is in VB.NET you *could* use that to help provide a VB6 approach that is
as easy.  Really, if you weren't so angry, you'd see that as a clear
definition by example.


> *or* b) inflame others?
>

See above.


>> If you have a solution put it in words here for the entire group to read.
>> It's put up or shut up time for you Karl.
>> My colleagues and I have lost respect for you Karl.
>> It would help to be more professional. Gives VB6 forum a bad name.
>
> Get a grip.  Time to regain your perspective, and consider your words more
> carefully.

Oh physician ........

> I'll leave both our words fully intact, below, so calmer heads can decide
> who's lost it here.
> --


Why, do you think those that might agree with you are incapable of looking
back in a thread ?  ;)
Author
16 Dec 2008 9:41 AM
Eduardo
I think that everyone has to ignore the writings of this stup¡d troll.

If the fact was that "unless I know who wrote the original file" for VB6, it
would be the same for every language. Simple logic.

If the fact was "It's very simple in [whatever language]", so it's possible,
(simple or not) to do it in VB6 without knowing who wrote the original file.

Of course this kind of simple logic may be too much...



Show quoteHide quote
"Bill McCarthy" <B***@localhost.com> escribió en el mensaje
news:uwJT7B2XJHA.5276@TK2MSFTNGP03.phx.gbl...
Author
16 Dec 2008 9:52 AM
Bill McCarthy
"Eduardo" <m*@mm.com> wrote in message
news:gi7t4r$8mu$1@news.motzarella.org...
>
> If the fact was "It's very simple in [whatever language]", so it's
> possible, (simple or not) to do it in VB6 without knowing who wrote the
> original file.
>

Exactly.  The part about not beign simple in VB6 compared to VB.NET still
applies.


> Of course this kind of simple logic may be too much...
>

Yeh well when you get the knowledge and experience with other languages such
as VB.NET and the power the framework provides, then the reality behind
those statements won't be difficult for you to grasp at all.  If of course
you don't know or aren't familiar with the .NET framework, then it's
understandable that the logic//reality may be too much.
Author
18 Dec 2008 11:14 PM
Kevin Provance
"Bill McCarthy" <B***@localhost.com> wrote in message
news:uL$Z6P2XJHA.5476@TK2MSFTNGP03.phx.gbl...

| Exactly.  The part about not beign simple in VB6 compared to VB.NET still
| applies.

beign?  You know you have McWilly flustered when he starts making such
errors.  <g>

But "beign" killfiled, he'll never know.
Author
16 Dec 2008 6:05 PM
Karl E. Peterson
Eduardo wrote:
> I think that everyone has to ignore the writings of this stup¡d troll.

Nailed it.

> If the fact was that "unless I know who wrote the original file" for VB6, it
> would be the same for every language. Simple logic.

"Bingeaux," as they say in France.

> Of course this kind of simple logic may be too much...

Except to the royal assho1es in our midst, yeah.
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
16 Dec 2008 6:05 PM
Karl E. Peterson
Bill McCarthy wrote:
> See above.

Assho1e.
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
17 Dec 2008 9:46 PM
Lou
Thanks Bill...


Show quoteHide quote
"Bill McCarthy" <B***@localhost.com> wrote in message
news:uwJT7B2XJHA.5276@TK2MSFTNGP03.phx.gbl...
>
>
> "Karl E. Peterson" <k***@mvps.org> wrote in message
> news:eScQG2xXJHA.2372@TK2MSFTNGP03.phx.gbl...
>> Lou wrote:
>>> What I am saying is no one has issued a solution for this problem and
>>> everyone agreed it is not solvable using VB6 unless I know who wrote the
>>> original file.
>>
>> That's *way* different than: "It's very simple in DotNet but..."
>>
>
> He spoke the truth.
>
>
>> It was the preface that I took issue with.
>
>
> Uh huh.. so we have yet another lengthy rant that actually doesn't help
> anyone because **you took issue** with reality.
>
>> You might as well say:
>>
>>> What I am saying is no one has issued a solution for this problem and
>>> everyone agreed it is not solvable unless I know who wrote the original
>>> file.
>>
>> That's just as accurate, although it doesn't make you look like an idiot
>> for thinking VB6 has any bearing on the situation.  What point is there
>> in adding "using VB6" to that sentence other than to either a)
>> demonstrate your lack of true understanding
>
> I think the lack of understanding is on your part.  He stated a simple
> honest fact.  you decide to attack because you take issue with that.
> If you *understood* what he was talking about with the example of how easy
> it is in VB.NET you *could* use that to help provide a VB6 approach that
> is as easy.  Really, if you weren't so angry, you'd see that as a clear
> definition by example.
>
>
>> *or* b) inflame others?
>>
>
> See above.
>
>
>>> If you have a solution put it in words here for the entire group to
>>> read.
>>> It's put up or shut up time for you Karl.
>>> My colleagues and I have lost respect for you Karl.
>>> It would help to be more professional. Gives VB6 forum a bad name.
>>
>> Get a grip.  Time to regain your perspective, and consider your words
>> more carefully.
>
> Oh physician ........
>
>> I'll leave both our words fully intact, below, so calmer heads can decide
>> who's lost it here.
>> --
>
>
> Why, do you think those that might agree with you are incapable of looking
> back in a thread ?  ;)
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
Author
16 Dec 2008 9:50 AM
Eduardo
"Lou" <lou.gar***@comcast.net> escribió en el mensaje
news:OnFkFXXWJHA.4488@TK2MSFTNGP04.phx.gbl...

> VB6 is not good in this area. It's very simple in DotNet but
> unfortunately I have to use VB6.

Instead of annoying people criticizing VB6 in a VB6 group, go and study the
issue for yourself: http://unicode.org/faq/utf_bom.html

Otherwise you are also trolling:
http://en.wikipedia.org/wiki/Troll_(Internet)?a
"An Internet troll, or simply troll in Internet slang, is someone who posts
controversial, inflammatory, irrelevant or off-topic messages in an online
community, such as an online discussion forum or chat room, with the
intention of provoking other users into an emotional response or to
generally disrupt normal on-topic discussion."
Author
16 Dec 2008 9:59 AM
Bill McCarthy
"Eduardo" <m*@mm.com> wrote in message
news:gi7tm7$ec2$1@news.motzarella.org...
> "Lou" <lou.gar***@comcast.net> escribió en el mensaje
> news:OnFkFXXWJHA.4488@TK2MSFTNGP04.phx.gbl...
>
>> VB6 is not good in this area. It's very simple in DotNet but
>> unfortunately I have to use VB6.
>
> Instead of annoying people criticizing VB6 in a VB6 group, go and study
> the issue for yourself: http://unicode.org/faq/utf_bom.html
>

Actually if you read the thread, you'll see that I and others suggested
looking at the BOM.

> Otherwise you are also trolling:

I think you not reading what has already been posted and still missing the
big part of this, and then in response calling people names is trolling.

How about you actually try to come up with a good clean solution for VB6
that deals with UTF-8, rather than call folks names ??
Author
16 Dec 2008 6:06 PM
Karl E. Peterson
Bill McCarthy wrote:
> Actually if you read the thread, you'll see that I am

Assho1e.
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
17 Dec 2008 9:51 PM
Lou
Finally some sanity and class.....


Show quoteHide quote
"Bill McCarthy" <B***@localhost.com> wrote in message
news:eSN9MU2XJHA.6064@TK2MSFTNGP05.phx.gbl...
>
> "Eduardo" <m*@mm.com> wrote in message
> news:gi7tm7$ec2$1@news.motzarella.org...
>> "Lou" <lou.gar***@comcast.net> escribió en el mensaje
>> news:OnFkFXXWJHA.4488@TK2MSFTNGP04.phx.gbl...
>>
>>> VB6 is not good in this area. It's very simple in DotNet but
>>> unfortunately I have to use VB6.
>>
>> Instead of annoying people criticizing VB6 in a VB6 group, go and study
>> the issue for yourself: http://unicode.org/faq/utf_bom.html
>>
>
> Actually if you read the thread, you'll see that I and others suggested
> looking at the BOM.
>
>> Otherwise you are also trolling:
>
> I think you not reading what has already been posted and still missing the
> big part of this, and then in response calling people names is trolling.
>
> How about you actually try to come up with a good clean solution for VB6
> that deals with UTF-8, rather than call folks names ??
>
>
>
Author
16 Dec 2008 10:30 AM
Mike Williams
"Eduardo" <m*@mm.com> wrote in message
news:gi7tm7$ec2$1@news.motzarella.org...

> http://en.wikipedia.org/wiki/Troll_(Internet)?a
> "An Internet troll, or simply troll in Internet slang, is someone who
> posts controversial, inflammatory, irrelevant or off-topic messages
> in an online community, such as an online discussion forum or chat
> room, with the intention of provoking other users into an emotional
> response or to generally disrupt normal on-topic discussion."

Yep. That's McCarthy alright. I wish he would stop his continual harrassment
of certain people as well. I'd complain to Microsoft about the dreadful
behaviour of one of their MVPs except for the fact that I don't think he is
an MVP any more.

Michael
Author
17 Dec 2008 2:42 PM
Paul Clement
On Tue, 16 Dec 2008 10:30:38 -0000, "Mike Williams" <M***@WhiskyAndCoke.com> wrote:

¤ > http://en.wikipedia.org/wiki/Troll_(Internet)?a
¤ > "An Internet troll, or simply troll in Internet slang, is someone who
¤ > posts controversial, inflammatory, irrelevant or off-topic messages
¤ > in an online community, such as an online discussion forum or chat
¤ > room, with the intention of provoking other users into an emotional
¤ > response or to generally disrupt normal on-topic discussion."
¤
¤ Yep. That's McCarthy alright. I wish he would stop his continual harrassment
¤ of certain people as well. I'd complain to Microsoft about the dreadful
¤ behaviour of one of their MVPs except for the fact that I don't think he is
¤ an MVP any more.

LOL! Try looking in a mirror!


Paul
~~~~
Microsoft MVP (Visual Basic)
Author
17 Dec 2008 4:34 PM
Mike Williams
"Paul Clement" <UseAdddressAtEndofMess***@swspectrum.com> wrote in message
news:tr3ik45jvl1fii5o8k759bu9l3vgoiuvjh@4ax.com...

> ¤ Yep. That's McCarthy alright. I wish he would stop his continual
> harrassment
> ¤ of certain people as well. I'd complain to Microsoft about the dreadful
> ¤ behaviour of one of their MVPs except for the fact that I don't think he
> is
> ¤ an MVP any more.
>
> LOL! Try looking in a mirror!

Laugh as much as you like, Clement. I don't care what you think. I know that
many people here, including yourself apparently, regard my own behaviour as
trolling but I don't care because I am not a troll. I'm just somebody who is
annoyed by McCarthy's constant harassment of certain people in this group
and of his repeated off topic posts in pursuance of his VB.Net crusade on
behalf of his handlers and of his blatant refusal to acknowledge any of his
own mistakes whilst he delights in belligerently pointing out what he
believes to be the mistakes of others. If McCarthy stops his nasty behaviour
then I will stop responding to him and to the things that he does.

I'm also annoyed by McCarthy's persistent refusal to answer a simple
question about his own MVP status which I think has probably been allowed to
lapse, possibly because of his behaviour in this group, and I really cannot
see why he is so shy of such things after he made such a fuss some time ago
when he posted lies in this group regarding my own MVP status and when he
repeatedly said that I had been "booted out" when my own MVP status was
allowed to lapse at the end of my then current tenure because I had publicly
been critising Micro$oft, which they did not like. And yet as soon as I used
the phrase "booted out" in respect of McCarthy he threatened to go crying to
his lawyers! What a childish idiot! What a little Mummy's boy! You're not
much better yourself either, Clement, since you appear to either agree with
or defend everything McCarthy does. I think you're both puppets, but I think
only one of you is currently an MVP puppet, and that's yourself!

Mike
Author
17 Dec 2008 6:35 PM
Paul Clement
On Wed, 17 Dec 2008 16:34:26 -0000, "Mike Williams" <M***@WhiskyAndCoke.com> wrote:

¤ > ¤ Yep. That's McCarthy alright. I wish he would stop his continual
¤ > harrassment
¤ > ¤ of certain people as well. I'd complain to Microsoft about the dreadful
¤ > ¤ behaviour of one of their MVPs except for the fact that I don't think he
¤ > is
¤ > ¤ an MVP any more.
¤ >
¤ > LOL! Try looking in a mirror!
¤
¤ Laugh as much as you like, Clement. I don't care what you think. I know that
¤ many people here, including yourself apparently, regard my own behaviour as
¤ trolling but I don't care because I am not a troll. I'm just somebody who is
¤ annoyed by McCarthy's constant harassment of certain people in this group
¤ and of his repeated off topic posts in pursuance of his VB.Net crusade on
¤ behalf of his handlers and of his blatant refusal to acknowledge any of his
¤ own mistakes whilst he delights in belligerently pointing out what he
¤ believes to be the mistakes of others. If McCarthy stops his nasty behaviour
¤ then I will stop responding to him and to the things that he does.

What nasty behavior? Now I don't condone the constant back and forth insults but he practically
ignores you now and you persist with your personal harassment. You're setting up a false argument to
justify your own behavior.

Nobody elected you newsgroup cop and just because you're annoyed by someone doesn't justify an
infantile attitude.

¤ I'm also annoyed by McCarthy's persistent refusal to answer a simple
¤ question about his own MVP status which I think has probably been allowed to
¤ lapse, possibly because of his behaviour in this group, and I really cannot
¤ see why he is so shy of such things after he made such a fuss some time ago
¤ when he posted lies in this group regarding my own MVP status and when he
¤ repeatedly said that I had been "booted out" when my own MVP status was
¤ allowed to lapse at the end of my then current tenure because I had publicly
¤ been critising Micro$oft, which they did not like. And yet as soon as I used
¤ the phrase "booted out" in respect of McCarthy he threatened to go crying to
¤ his lawyers! What a childish idiot! What a little Mummy's boy! You're not
¤ much better yourself either, Clement, since you appear to either agree with
¤ or defend everything McCarthy does. I think you're both puppets, but I think
¤ only one of you is currently an MVP puppet, and that's yourself!

This is all nonsense and not relevant to the group topic. You constantly whine about off topic posts
and the mere mention of .NET, but then you turn around and compound the problem with your rants and
personal insults. You're not doing any of this for the sake of the newsgroup - it's to satisfy your
own ego.

I don't have to defend or agree with anyone to identify this sort of behavior as childish (if you
really want to bring up the topic of "childish idiots").


Paul
~~~~
Microsoft MVP (Visual Basic)
Author
17 Dec 2008 9:54 PM
Lou
Karl is acting much more immature than everyone else.

Show quoteHide quote
"Mike Williams" <M***@WhiskyAndCoke.com> wrote in message
news:OUPUMVGYJHA.5272@TK2MSFTNGP04.phx.gbl...
> "Paul Clement" <UseAdddressAtEndofMess***@swspectrum.com> wrote in message
> news:tr3ik45jvl1fii5o8k759bu9l3vgoiuvjh@4ax.com...
>
>> ¤ Yep. That's McCarthy alright. I wish he would stop his continual
>> harrassment
>> ¤ of certain people as well. I'd complain to Microsoft about the dreadful
>> ¤ behaviour of one of their MVPs except for the fact that I don't think
>> he is
>> ¤ an MVP any more.
>>
>> LOL! Try looking in a mirror!
>
> Laugh as much as you like, Clement. I don't care what you think. I know
> that many people here, including yourself apparently, regard my own
> behaviour as trolling but I don't care because I am not a troll. I'm just
> somebody who is annoyed by McCarthy's constant harassment of certain
> people in this group and of his repeated off topic posts in pursuance of
> his VB.Net crusade on behalf of his handlers and of his blatant refusal to
> acknowledge any of his own mistakes whilst he delights in belligerently
> pointing out what he believes to be the mistakes of others. If McCarthy
> stops his nasty behaviour then I will stop responding to him and to the
> things that he does.
>
> I'm also annoyed by McCarthy's persistent refusal to answer a simple
> question about his own MVP status which I think has probably been allowed
> to lapse, possibly because of his behaviour in this group, and I really
> cannot see why he is so shy of such things after he made such a fuss some
> time ago when he posted lies in this group regarding my own MVP status and
> when he repeatedly said that I had been "booted out" when my own MVP
> status was allowed to lapse at the end of my then current tenure because I
> had publicly been critising Micro$oft, which they did not like. And yet as
> soon as I used the phrase "booted out" in respect of McCarthy he
> threatened to go crying to his lawyers! What a childish idiot! What a
> little Mummy's boy! You're not much better yourself either, Clement, since
> you appear to either agree with or defend everything McCarthy does. I
> think you're both puppets, but I think only one of you is currently an MVP
> puppet, and that's yourself!
>
> Mike
>
>
Author
18 Dec 2008 3:53 AM
Bill McCarthy
hi Lou,

"Lou" <lou.gar***@comcast.net> wrote in message
news:%233C$EIJYJHA.208@TK2MSFTNGP03.phx.gbl...
> Karl is acting much more immature than everyone else.
>

Yeh sadly, that appears to be his new game here, at least judging by his
posts since he recently came back.
Author
17 Dec 2008 9:52 PM
Lou
hmmm wonder why...


Show quoteHide quote
"Mike Williams" <M***@WhiskyAndCoke.com> wrote in message
news:OWwUSl2XJHA.208@TK2MSFTNGP03.phx.gbl...
> "Eduardo" <m*@mm.com> wrote in message
> news:gi7tm7$ec2$1@news.motzarella.org...
>
>> http://en.wikipedia.org/wiki/Troll_(Internet)?a
>> "An Internet troll, or simply troll in Internet slang, is someone who
>> posts controversial, inflammatory, irrelevant or off-topic messages
>> in an online community, such as an online discussion forum or chat
>> room, with the intention of provoking other users into an emotional
>> response or to generally disrupt normal on-topic discussion."
>
> Yep. That's McCarthy alright. I wish he would stop his continual
> harrassment of certain people as well. I'd complain to Microsoft about the
> dreadful behaviour of one of their MVPs except for the fact that I don't
> think he is an MVP any more.
>
> Michael
>
>
Author
17 Dec 2008 9:50 PM
Lou
My intention was to solve a problem...period.
VB6 is a great tool and have used it for years.
I have a project that needs a solution. I posted the problem
hoping to get help not get insulted. I did not take the first shot here.
I have not swore at anybody or insulted anybody.

-Lou


Show quoteHide quote
"Eduardo" <m*@mm.com> wrote in message
news:gi7tm7$ec2$1@news.motzarella.org...
> "Lou" <lou.gar***@comcast.net> escribió en el mensaje
> news:OnFkFXXWJHA.4488@TK2MSFTNGP04.phx.gbl...
>
>> VB6 is not good in this area. It's very simple in DotNet but
>> unfortunately I have to use VB6.
>
> Instead of annoying people criticizing VB6 in a VB6 group, go and study
> the issue for yourself: http://unicode.org/faq/utf_bom.html
>
> Otherwise you are also trolling:
> http://en.wikipedia.org/wiki/Troll_(Internet)?a
> "An Internet troll, or simply troll in Internet slang, is someone who
> posts controversial, inflammatory, irrelevant or off-topic messages in an
> online community, such as an online discussion forum or chat room, with
> the intention of provoking other users into an emotional response or to
> generally disrupt normal on-topic discussion."
>
Author
8 Dec 2008 7:59 PM
mayayana
> I am using VB6
> This seems to be the right group???

  Yes, this is a VB6 group. And you can use FileSystemObject
if you want to, but it's not recommended for the reasons I
listed. scrrun.dll, which is where FSO comes from, is the Scripting
Runtime. It's a slow, unnecessary COM library that was designed
especially for scripting. There are VB functions for most of what
FSO does, and there are also APIs. I think someone also wrote a
FSO replacement class, but I don't have a link to that offhand.
Maybe someone else will post it.

Here's what you're probably doing:

  Set ts = fs.OpenTextFile("MyFile.txt",ForReading)
  s = ts.ReadAll
  Set ts = Nothing

Here's a VB replacement that doesn't need the FSO:

Public Function ReadAll(fPath As String) As String
  '--open a text file and read it into string.

  Dim FF As Integer, iAttr As Integer
  Dim LFil As Long
  Dim s As String
    On Error Resume Next
    Err.Clear
    '-- test that file exists.
   iAttr = GetAttr(fPath)
    If (Err.Number <> 0) Then
      ReadAll = ""
      Exit Function
    End If
    SetAttr fPath, 0

    FF = FreeFile()
    Open fPath For Input As #FF
      LFil = LOF(FF)
      s = Input$(LFil, #FF)
    Close #FF

   SetAttr fPath, iAttr
   ReadAll = s
End Function

    For some reason the FSO and Dictionary object got
associated with VB6. The O'Reilly VB6 language reference
includes them as though they were core VB6 elements,
but they are not. Either way, if you want to keep using
the FSO you should download the Windows Script Host
help file that I linked before. That's where the FSO functions
are documented.
Author
8 Dec 2008 8:09 PM
Bill McCarthy
I doubt that works with Unicode.


Show quoteHide quote
"mayayana" <mayaXXy***@rcXXn.com> wrote in message
news:uTk7r8WWJHA.4728@TK2MSFTNGP02.phx.gbl...
>> I am using VB6
>> This seems to be the right group???
>
>  Yes, this is a VB6 group. And you can use FileSystemObject
> if you want to, but it's not recommended for the reasons I
> listed. scrrun.dll, which is where FSO comes from, is the Scripting
> Runtime. It's a slow, unnecessary COM library that was designed
> especially for scripting. There are VB functions for most of what
> FSO does, and there are also APIs. I think someone also wrote a
> FSO replacement class, but I don't have a link to that offhand.
> Maybe someone else will post it.
>
> Here's what you're probably doing:
>
>  Set ts = fs.OpenTextFile("MyFile.txt",ForReading)
>  s = ts.ReadAll
>  Set ts = Nothing
>
> Here's a VB replacement that doesn't need the FSO:
>
> Public Function ReadAll(fPath As String) As String
>  '--open a text file and read it into string.
>
>  Dim FF As Integer, iAttr As Integer
>  Dim LFil As Long
>  Dim s As String
>    On Error Resume Next
>    Err.Clear
>    '-- test that file exists.
>   iAttr = GetAttr(fPath)
>    If (Err.Number <> 0) Then
>      ReadAll = ""
>      Exit Function
>    End If
>    SetAttr fPath, 0
>
>    FF = FreeFile()
>    Open fPath For Input As #FF
>      LFil = LOF(FF)
>      s = Input$(LFil, #FF)
>    Close #FF
>
>   SetAttr fPath, iAttr
>   ReadAll = s
> End Function
>
>    For some reason the FSO and Dictionary object got
> associated with VB6. The O'Reilly VB6 language reference
> includes them as though they were core VB6 elements,
> but they are not. Either way, if you want to keep using
> the FSO you should download the Windows Script Host
> help file that I linked before. That's where the FSO functions
> are documented.
>
>
Author
8 Dec 2008 11:31 PM
expvb
"Lou" <lou.gar***@comcast.net> wrote in message
news:ud5t8WWWJHA.1576@TK2MSFTNGP03.phx.gbl...
> What does this parameter do?
> Set ts = fs.OpenTextFile("MyFile.txt",ForReading, False, TristateMixed)
>
> Can it determine what format the file is and open it accordingly?
> Unicode,UTF-8, etc????

There is no 100% fool proof method. It's best if you use different
extensions. Unicode file size is always even, so if the file size is odd,
it's ANSI or UTF-8.

Unicode text files usually begin with FF, FE for little indian(usually the
default for Intel based computers), and FE, FF for big indian. They have
bytes with zeros if they have characters with codes below 256.

UTF-8 usually looks like ANSI files until you encode characters in the range
128+. In Windows, Notepad and other programs adds bytes sequences at the
beginning, EF, BB, BF. But these are not necessarily present, it depends on
the application that is used to create them. See "Byte-order mark" topic
here:

http://en.wikipedia.org/wiki/UTF-8

"Description" topic shows how UTF-8 files are encoded.

Here is a free Hex editor that you can use to examine byte values:

http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm

Try using Notepad to save a text file as Unicode, UTF-8, and see what it
looks like.

Here is a code snippet that shows how to read an entire file into a byte
array, and displays the first few bytes:

Dim f As Integer
Dim FileContents() As Byte
Dim i As Long

f = FreeFile
Open FileName For Binary Access Read Shared As #f
' Allocate buffer for the entire file
ReDim FileContents(1 To LOF(f))
' Read the entire file into memory
Get f, , FileContents
Close f

For i = 1 To 5
    Debug.Print i, Hex(FileContents(i))
Next
Author
9 Dec 2008 3:13 PM
Lou
Thanks.

Here is what I have done but I am not happy with this method.

Public Function GetFileEncoding(sFileName As String) As String
    Dim FileNum As Integer
    Dim bytX() As Byte
    Dim i As Long

    FileNum = FreeFile

    Open sFileName For Binary As #FileNum
    i = LOF(FileNum)
    ReDim bytX(i)
    Get #FileNum, , bytX()
    Close #FileNum

    Dim c As String
    c = bytX(0)

    If bytX(0) = 255 Or bytX(0) = 254 Then
        GetFileEncoding = "utf-16"
    ElseIf IsUTF8(c, 1) = True Then
        GetFileEncoding = "utf-8"
    Else
        GetFileEncoding = "us-ascii"
    End If


End Function

Public Function IsUTF8(ByRef Text As String, Optional ByVal lngReadSize As
Long = 2048) As Boolean
    Dim bytArray() As Byte, lngArraySize As Long, lngBytes As Long, lngPos
As Long, lngUTF8 As Long
    lngArraySize = LenB(Text)
    If lngArraySize Then
        If lngReadSize > 0 Then
            ' see if we take the entire string or just a part of it
            If lngReadSize > lngArraySize Then
                ' take everything
                lngReadSize = lngArraySize
                bytArray = Text
            Else
                ' take just the part of it
                bytArray = LeftB$(Text, lngReadSize)
            End If
            ' now keep going until we have gone through the entire buffer
            Do While lngPos < lngReadSize
                ' the code here is just standard UTF-8 decoding
                If bytArray(lngPos) < &H80 Then
                    lngPos = lngPos + 1
                ElseIf bytArray(lngPos) < &HC0 Then
                    Exit Function
                ElseIf (bytArray(lngPos) >= &HC0) And (bytArray(lngPos) <=
&HFD) Then
                    If (bytArray(lngPos) And &HFC) = &HFC Then
                        lngBytes = 5
                    ElseIf (bytArray(lngPos) And &HF8) = &HF8 Then
                        lngBytes = 4
                    ElseIf (bytArray(lngPos) And &HF0) = &HF0 Then
                        lngBytes = 3
                    ElseIf (bytArray(lngPos) And &HE0) = &HE0 Then
                        lngBytes = 2
                    ElseIf (bytArray(lngPos) And &HC0) = &HC0 Then
                        lngBytes = 1
                    End If
                    For lngPos = (lngPos + 1) To (lngPos + lngBytes)
                        If Not ((bytArray(lngPos) >= &H80) And
(bytArray(lngPos) <= &HBF)) Then
                            Exit Function
                        ElseIf lngPos >= lngReadSize Then
                            Exit Do
                        End If
                    Next lngPos
                    'lngUTF8 = lngUTF8 + 1
                Else
                    lngPos = lngPos + 1
                End If
            Loop
            IsUTF8 = True 'lngUTF8 > 0
        End If
    End If
End Function





Show quoteHide quote
"expvb" <nob***@cox.net> wrote in message
news:ezomz0YWJHA.5496@TK2MSFTNGP04.phx.gbl...
> "Lou" <lou.gar***@comcast.net> wrote in message
> news:ud5t8WWWJHA.1576@TK2MSFTNGP03.phx.gbl...
>> What does this parameter do?
>> Set ts = fs.OpenTextFile("MyFile.txt",ForReading, False, TristateMixed)
>>
>> Can it determine what format the file is and open it accordingly?
>> Unicode,UTF-8, etc????
>
> There is no 100% fool proof method. It's best if you use different
> extensions. Unicode file size is always even, so if the file size is odd,
> it's ANSI or UTF-8.
>
> Unicode text files usually begin with FF, FE for little indian(usually the
> default for Intel based computers), and FE, FF for big indian. They have
> bytes with zeros if they have characters with codes below 256.
>
> UTF-8 usually looks like ANSI files until you encode characters in the
> range 128+. In Windows, Notepad and other programs adds bytes sequences at
> the beginning, EF, BB, BF. But these are not necessarily present, it
> depends on the application that is used to create them. See "Byte-order
> mark" topic here:
>
> http://en.wikipedia.org/wiki/UTF-8
>
> "Description" topic shows how UTF-8 files are encoded.
>
> Here is a free Hex editor that you can use to examine byte values:
>
> http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm
>
> Try using Notepad to save a text file as Unicode, UTF-8, and see what it
> looks like.
>
> Here is a code snippet that shows how to read an entire file into a byte
> array, and displays the first few bytes:
>
> Dim f As Integer
> Dim FileContents() As Byte
> Dim i As Long
>
> f = FreeFile
> Open FileName For Binary Access Read Shared As #f
> ' Allocate buffer for the entire file
> ReDim FileContents(1 To LOF(f))
> ' Read the entire file into memory
> Get f, , FileContents
> Close f
>
> For i = 1 To 5
>    Debug.Print i, Hex(FileContents(i))
> Next
>
>
Author
18 Dec 2008 3:03 AM
mayayana
You didn't say how you're getting the file from
FTP. Given that you're using FSO and ADODB it sounds
like you've adapted your code from VBScript. But if
you're carrying out the server conversation yourself
then you should get the file type as part of the header.
Example:
  Content-Type: text/plain; charset=UTF-8

  (Of course, that's not so hard to do in VB, but I don't
know if you can do your own downloading in .Net. There
you might have to use some sort of bloated wrapper around
a wrapper around IE. :)

Show quoteHide quote
> Thanks.
>
> Here is what I have done but I am not happy with this method.
Author
18 Dec 2008 4:00 AM
Bill McCarthy
"mayayana" <mayaXXy***@rcXXn.com> wrote in message
news:O2q4PzLYJHA.1532@TK2MSFTNGP03.phx.gbl...
>
> Of course, that's not so hard to do in VB, but I don't
> know if you can do your own downloading in .Net. There
> you might have to use some sort of bloated wrapper around
> a wrapper around IE.

If you don't know then why speculate ?  You're clearly wrong, but was the
intent of your post to encourage discussion about .NET in here, or were you
again just throwing ignorant jabs ?
Author
18 Dec 2008 5:24 AM
mayayana
>
> If you don't know then why speculate ?  You're clearly wrong, but was the
> intent of your post to encourage discussion about .NET in here, or were
you
> again just throwing ignorant jabs ?
>

   Something about your brilliant and notably cogent
arguments reminds me of the yelping of a neurotic
poodle. Isn't that strange? I can't imagine....
Author
18 Dec 2008 5:30 AM
Bill McCarthy
"mayayana" <mayaXXy***@rcXXn.com> wrote in message
news:uML65BNYJHA.1188@TK2MSFTNGP05.phx.gbl...
> >
>> If you don't know then why speculate ?  You're clearly wrong, but was the
>> intent of your post to encourage discussion about .NET in here, or were
> you
>> again just throwing ignorant jabs ?
>>
>
>   Something about your brilliant and notably cogent
> arguments


Correct so far ....

> reminds me of the yelping of a neurotic
> poodle. Isn't that strange?

No not really. It's call projecting.  You see you posted ignorant jabs
trying to get a response. IOW: you behaved like the little neurotic poodle
yapping at the door.  Then when you get growled at, you think the other dog
started it.


> I can't imagine....
>

Obviously.
Author
18 Dec 2008 5:46 AM
Karl E. Peterson
Bill McCarthy wrote:
>> reminds me of the yelping of a neurotic
>> poodle. Isn't that strange?
>
> No not really. It's call projecting.  You see you posted ignorant jabs
> trying to get a response. IOW: you behaved like the little neurotic poodle
> yapping at the door.  Then when you get growled at, you think the other dog
> started it.

Heh, okay, so now you're gonna Go All Juan on us, huh? <chuckle>
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
18 Dec 2008 6:00 AM
Bill McCarthy
Show quote Hide quote
"Karl E. Peterson" <k***@mvps.org> wrote in message
news:e1j4vPNYJHA.208@TK2MSFTNGP03.phx.gbl...
> Bill McCarthy wrote:
>>> reminds me of the yelping of a neurotic
>>> poodle. Isn't that strange?
>>
>> No not really. It's call projecting.  You see you posted ignorant jabs
>> trying to get a response. IOW: you behaved like the little neurotic
>> poodle
>> yapping at the door.  Then when you get growled at, you think the other
>> dog
>> started it.
>
> Heh, okay, so now you're gonna Go All Juan on us, huh? <chuckle>
> --


Wow.  Why are you trying to slur him in here ? Guess after all he was right
about you.
Author
18 Dec 2008 8:23 PM
Karl E. Peterson
Bill McCarthy wrote:
> Wow.  Why are you trying to slur him in here ? Guess after all he was right
> about you.

So you consider that when someone is compared to you, that's a slur on *them*?

Gotcha...
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
19 Dec 2008 12:04 AM
Bill McCarthy
"Karl E. Peterson" <k***@mvps.org> wrote in message
news:%23EDGJ6UYJHA.5336@TK2MSFTNGP02.phx.gbl...
> Bill McCarthy wrote:
>> Wow.  Why are you trying to slur him in here ? Guess after all he was
>> right
>> about you.
>
> So you consider that when someone is compared to you, that's a slur on
> *them*?
>
> Gotcha...
> --

I'm not going to entertain your personal attacks on Juan.  He was right
about you, and that is very very sad.  You had no right, no place to drag
his name into this newsgroup.
Author
19 Dec 2008 1:02 AM
Karl E. Peterson
Bill McCarthy wrote:
> "Karl E. Peterson" <k***@mvps.org> wrote ...
>> Bill McCarthy wrote:
>>> Wow.  Why are you trying to slur him in here ? Guess after all he was
>>> right
>>> about you.
>>
>> So you consider that when someone is compared to you, that's a slur on
>> *them*?
>>
>> Gotcha...
>
> I'm not going to entertain

LOL!  Is *that* what you think you're doing here???  Entertaining us?  Or, are you
really trying to entertain some hidden cadre of weirdos.NET who only make cameo
appearances when they feel you need a little ego boost to keep ya going?

> You had no right, no place to drag his name into this newsgroup.

Nice try, you little Juanabbe!  You can do better.  Why don't you run along, and
practice somewhere else?
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
19 Dec 2008 1:07 AM
Kevin Provance
Some more advice you should probably take, dick face.  Pretty cowardly to
talk about people you refuse to ackowledge.  Or was that a stipulation to
get back on MSFT's good graces?  Killfile the guy you repeatidly attacked
because he got under your skin?  Strange I'm the only one, and not Mike, or
Karl, etc.  It's nice to know I got to you that badly.  Apparently, the
truth does hurt.  :-)

Such a puppet.

Show quoteHide quote
"Bill McCarthy" <B***@localhost.com> wrote in message
news:uRSuT4WYJHA.256@TK2MSFTNGP06.phx.gbl...
|
| "Karl E. Peterson" <k***@mvps.org> wrote in message
| news:%23EDGJ6UYJHA.5336@TK2MSFTNGP02.phx.gbl...
| > Bill McCarthy wrote:
| >> Wow.  Why are you trying to slur him in here ? Guess after all he was
| >> right
| >> about you.
| >
| > So you consider that when someone is compared to you, that's a slur on
| > *them*?
| >
| > Gotcha...
| > --
|
| I'm not going to entertain your personal attacks on Juan.  He was right
| about you, and that is very very sad.  You had no right, no place to drag
| his name into this newsgroup.
|
Author
18 Dec 2008 2:27 PM
mayayana
> Heh, okay, so now you're gonna Go All Juan on us, huh? <chuckle>
> --

  Let me guess. Juan was a case of a mildly paranoid
barroom thug who joined a 70's encounter group and
"upgraded" his trip?  :)
Author
18 Dec 2008 2:24 PM
mayayana
>   You didn't say how you're getting the file from
> FTP. Given that you're using FSO and ADODB it sounds
> like you've adapted your code from VBScript. But if
> you're carrying out the server conversation yourself
> then you should get the file type as part of the header.
> Example:
>   Content-Type: text/plain; charset=UTF-8
>
  Another thought with this: I think that scripters
sometimes use msxmlx.dll (where x is a number)
to download files. I've never tried msxml and don't
know much about it, but I took a quick look and --
unlike the commonly used IE library functions like
URLDownloadToFile -- it seems to have functions like
GetResponseHeader, to return the server response.
The server sends this header prepended to the
requested file. It's a lot like an email header -- similar
format with lots of possible fields, many of which
are not critical. Here's part of one:

Server response: 200 - OK
Server Header: HTTP/1.1 200 OK
Date: Thu, 18 Dec 2008 03:57:02 GMT
Content-Language: en-US
Content-Type: text/html; charset=UTF-8

  The server tells you the result of your request.
In this case it's 200, meaning "OK. Valid request.
Here comes the whole thing."

  It might be feasible to get that header, search for
what comes between "charset" and a return, then if
it's not found assume UTF8. (I'm not certain, but I
think that has become the default these days.)

  I also don't know how common msxml is. The methods
above apparently require v. 3+. But I'm on Win98SE, with
the original IE version, and I have both v.3 and v.4 installed,
so I guess msxml must be fairly ubiquitous.
Author
19 Dec 2008 4:04 AM
Lou
I am using the iNet control to get the files. The getHeader function says
it's only good for HTTP Not FTP?

objFTP.Execute , "GET " & Chr(34) & strStories(i) & Chr(34) & " " & strFile

"The GetHeader method is used to retrieve header text from an HTTP file"

I'll keep trying...
Thanks for the help.


-Lou


Show quoteHide quote
"mayayana" <mayaXXy***@rcXXn.com> wrote in message
news:en0XpvRYJHA.2280@TK2MSFTNGP06.phx.gbl...
>>   You didn't say how you're getting the file from
>> FTP. Given that you're using FSO and ADODB it sounds
>> like you've adapted your code from VBScript. But if
>> you're carrying out the server conversation yourself
>> then you should get the file type as part of the header.
>> Example:
>>   Content-Type: text/plain; charset=UTF-8
>>
>  Another thought with this: I think that scripters
> sometimes use msxmlx.dll (where x is a number)
> to download files. I've never tried msxml and don't
> know much about it, but I took a quick look and --
> unlike the commonly used IE library functions like
> URLDownloadToFile -- it seems to have functions like
> GetResponseHeader, to return the server response.
> The server sends this header prepended to the
> requested file. It's a lot like an email header -- similar
> format with lots of possible fields, many of which
> are not critical. Here's part of one:
>
> Server response: 200 - OK
> Server Header: HTTP/1.1 200 OK
> Date: Thu, 18 Dec 2008 03:57:02 GMT
> Content-Language: en-US
> Content-Type: text/html; charset=UTF-8
>
>  The server tells you the result of your request.
> In this case it's 200, meaning "OK. Valid request.
> Here comes the whole thing."
>
>  It might be feasible to get that header, search for
> what comes between "charset" and a return, then if
> it's not found assume UTF8. (I'm not certain, but I
> think that has become the default these days.)
>
>  I also don't know how common msxml is. The methods
> above apparently require v. 3+. But I'm on Win98SE, with
> the original IE version, and I have both v.3 and v.4 installed,
> so I guess msxml must be fairly ubiquitous.
>
>
Author
19 Dec 2008 5:29 AM
mayayana
> I am using the iNet control to get the files. The getHeader function says
> it's only good for HTTP Not FTP?
>

I've never used that. It might be worth testing getHeader,
though. If it doesn't work you might also try using HTTP. I don't
really know exactly what the difference is between the
two. It may just be a matter of different commands, etc.
I find that if I use winsock and talk directly to an FTP server,
I seem to have no trouble sending:
  "GET " & FilePath & " HTTP/1.0"
The FTP server just sends the file to me with an HTTP
header.

   Looking at the Execute method docs it looks like that
works similarly, using the same method for HTTP or FTP,
and just leaving it to you to send an appropriate request
string.


Show quoteHide quote
> objFTP.Execute , "GET " & Chr(34) & strStories(i) & Chr(34) & " " &
strFile
>
> "The GetHeader method is used to retrieve header text from an HTTP file"
>
> I'll keep trying...
> Thanks for the help.
>
>
> -Lou
>
>
> "mayayana" <mayaXXy***@rcXXn.com> wrote in message
> news:en0XpvRYJHA.2280@TK2MSFTNGP06.phx.gbl...
> >>   You didn't say how you're getting the file from
> >> FTP. Given that you're using FSO and ADODB it sounds
> >> like you've adapted your code from VBScript. But if
> >> you're carrying out the server conversation yourself
> >> then you should get the file type as part of the header.
> >> Example:
> >>   Content-Type: text/plain; charset=UTF-8
> >>
> >  Another thought with this: I think that scripters
> > sometimes use msxmlx.dll (where x is a number)
> > to download files. I've never tried msxml and don't
> > know much about it, but I took a quick look and --
> > unlike the commonly used IE library functions like
> > URLDownloadToFile -- it seems to have functions like
> > GetResponseHeader, to return the server response.
> > The server sends this header prepended to the
> > requested file. It's a lot like an email header -- similar
> > format with lots of possible fields, many of which
> > are not critical. Here's part of one:
> >
> > Server response: 200 - OK
> > Server Header: HTTP/1.1 200 OK
> > Date: Thu, 18 Dec 2008 03:57:02 GMT
> > Content-Language: en-US
> > Content-Type: text/html; charset=UTF-8
> >
> >  The server tells you the result of your request.
> > In this case it's 200, meaning "OK. Valid request.
> > Here comes the whole thing."
> >
> >  It might be feasible to get that header, search for
> > what comes between "charset" and a return, then if
> > it's not found assume UTF8. (I'm not certain, but I
> > think that has become the default these days.)
> >
> >  I also don't know how common msxml is. The methods
> > above apparently require v. 3+. But I'm on Win98SE, with
> > the original IE version, and I have both v.3 and v.4 installed,
> > so I guess msxml must be fairly ubiquitous.
> >
> >
>
>
Author
19 Dec 2008 2:20 PM
Bob Butler
Show quote Hide quote
"mayayana" <mayaXXy***@rcXXn.com> wrote in message
news:eiHfZpZYJHA.5272@TK2MSFTNGP04.phx.gbl...
>
>> I am using the iNet control to get the files. The getHeader function says
>> it's only good for HTTP Not FTP?
>>
>
> I've never used that. It might be worth testing getHeader,
> though. If it doesn't work you might also try using HTTP. I don't
> really know exactly what the difference is between the
> two. It may just be a matter of different commands, etc.
> I find that if I use winsock and talk directly to an FTP server,
> I seem to have no trouble sending:
>  "GET " & FilePath & " HTTP/1.0"
> The FTP server just sends the file to me with an HTTP
> header.

I think you'll find that to be very dependent on the FTP server.  I don't
know if an HTTP format option has been added to newer FTP standards but it's
never been part of the RFC specs for FTP in the past; for an example see
http://www.faqs.org/rfcs/rfc959.html