Am 22.09.2019 um 21:09 schrieb Mayayana:
> "Schmidt" <n...@vbRichClient.com> wrote
>
> | > | E.g. what you wrote out as Base64-Text in your DemoCode,
> | > | is unnecessarily blown-up two UTF16-LE TextFormat,
> | > | which is twice as large as the written file needs to be.
> | > |
> | >
> | > Interesting. It does no such thing on my end.
> |
> | Please check again, I'm getting (when encoding a 3MB-TestFile), not
> | the expected 4MB (Base64 "blows up" the bin-content by factor 1.33),
> | but 8MB instead - when using your code...
> |
>
> This is intriguing. And annoying. My code was fine...
No, it wasn't - because in your prior code you did *not* set
the Charset-Property of the Stream-Object - and thus used
the default (which is "Unicode" aka "UTF16-LE" on Windows).
> ...until I tried yours with the utf-8. It then started saving
> as unicode, like you said.
Arrgh, could you please stick to the truth in a public NewsGroup.
Such "face-saving excuses" are exactly, how "misleading myths"
will take root.
> After some searching online it seems that ADODB
> 1) sniffs text and decides what it should be and
> 2) maintains some kind of memory as to its default format.
Nope, the ADO.Stream Object does no such thing.
It was (as said above), just using it's default-charset,
which you failed to specify explicitely (in both -
the read- and write-directions).
> My resulting speeds for the 25 MB file are .75 and 1.0.
> Pretty close to the original. With your updated code I'm
> getting .95 and 1.51.
I've done such a test now (after finding a 26MB-file here),
and the speeds were - as expected - identical (using my -
as well as your updated versions).
> So the only real difference is that my code is pretty
> and easy to read, while yours is confusing and needs
> editing before use. :)
No - you can ridicule my coding-style as you like -
but that does not change the fact, that your code (still)
is a perfect example for "spaghetti", seriously.
Really - it's not the coding-style which decides about
"spaghetti" or not, it's whether you applied "modularization",
KISS- and DRY-principles.
On my WebServer I use these VBScript-functions I've posted
via an Include-File (which ASP supports, but the WSH sadly not).
And thus my "UserCode" (the one that I've had to type in my Editor)
is really only this one here (leaving out the Timing-Code):
'--------------------
Dim File, bInp, sB64
File = WScript.Arguments(0)
bInp = ReadBytesFromFile(File)
If MsgBox("Click yes to encode (no to decode)", vbYesNo) = vbYes Then
sB64 = Base64Encode(bInp)
WriteBytesToFile File & "-64.txt", StringToBytes(sB64, "x-ansi")
Else
sB64 = BytesToString(bInp, "x-ansi")
WriteBytesToFile File & "-64.dat", Base64Decode(sB64)
End If
'------------------
Furthermore, my (relatively unnecessary) fix for a bit more speed,
was only applied in a single small Function, which is also
documenting the functionality of its handful of Lines over
its given Function-name (also later in UserCode, by using that Name).
All the other UserCode (spread over dozens of other *.asp-Files),
will now automatically profit from that little speed-up-change,
because it was done on an *include-file*.
Whereas in such non-generic code as yours, you had to actually
make a change in *two* (much harder to find) places, to fix "a bug".
And no other CodeModule of yours will profit from that change
(who knows, where else you used such non-function-encapsulated stuff).
> But it is discouraging that ADODB is as undependable
> in its mangling of text as FSO is.
As already said, such statements will only create further myths
in the community - nobody really needs or wants that...
Please run the following Single-Line-Script:
MsgBox CreateObject("ADODB.Stream").Charset
It will answer with: "Unicode"
(which is synonymous with "UTF16-LE" - and this will be reported
also on machines with an english locale - I've just checked that here)
Olaf