On Fri, 2 Sep 2005, Daniel Johnson wrote:
> I offer the following with NO WARRANTY.
Offer accepted. That's always acceptable.
> . . . . . . . . . . . . . . . . .. . . I am enclosing a VBScript file
> that should perform conversion from Latin-1 to UTF-8. I haven't tested
> this. Also, I never did figure out how to use command-line args with
> VBS, so you'll have to hardcode the input and output filenames each time
The VBScript can be modified to be work when called from an entry on
the right-click ("context") menu associated with the input file.
However, that requires messing with the Windows Registry, and
most noncommercial people are leery (as I am) of distributing material
that requires Registry changes, so in fact your script as it stands
is a very safe solution.
Being somewhat unicode-resistant, I was not familiar with the details
of conversion. I may or may not wind up using your routine, but it
makes it very clear what the characters in a unicoded file look like,
and I was unaware of that.
Thank you for such concrete and clear help.
-- Tom
*********************************************************************
> '==== begin VBScript code ====
>
> Option Explicit
>
> Dim sInFileName, sOutFileName
>
> sInFileName = "" ' Filename you wish to convert (with full path)
> sOutFileName = "" ' Filename you want for the output
>
> Dim oFSO
> Dim oInFile, sInString
> Dim oOutFile, sOutString
> Dim i, s
> Dim sTransArray(255)
>
> 'Populate the translation table
> For i = 128 To 191
> sTransArray(i) = chr(&HC2) & chr(i)
> Next
> For i = 192 To 255
> sTransArray(i) = chr(&HC3) & chr(i - 64)
> Next
>
> 'Read the input file as a single string
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> Set oInFile = oFSO.OpenTextFile(sInFileName, 1, False, 0)
> sInString = oInFile.ReadAll
> oInFile.Close
> Set oInFile = Nothing
>
> 'Perform char-by-char translation
> sOutString = ""
> For i = 0 To Len(sInString)
> s = Mid(sInString, i, 1)
> If Asc(s) < 128 Then
> sOutString = sOutString & s
> Else
> sOutString = sOutString & sTransArray(Asc(s))
> End If
> Next
>
> 'Write the resulting file to the output file
> Set oOutFile = oFSO.OpenTextFile(sOutFileName, 2, True, 0)
> oOutFile.Write(sOutString)
> oOutFile.Close
>
> 'Perform final housekeeping
> Set oOutFile = Nothing
> Set oFSO = Nothing
>
> End
>
> '==== end VBScript code ====
_______________________________________________
lilypond-user mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-user