Or, for someone with a C compiler, the poor-man's algorithm is:
for ( unsigned int i = 0; i < length; i++ ) { if ( (unsigned char)line1[i] > 127 ) { *line2++ = (char)(192 + (((unsigned char)line1[ i ]) / 64)); *line2++ = (char)(128 + (((unsigned char)line1[ i ]) % 64)); } else { *line2++ = line[ i ]; } } But in general, the quickest solution is to load the file in Notepad, and save as UTF-8. regards, Hans. ----- Original Message ----- From: "Daniel Johnson" <[EMAIL PROTECTED]> To: <lilypond-user@gnu.org> Cc: <[EMAIL PROTECTED]>; "Mats Bengtsson" <[EMAIL PROTECTED]> Sent: Friday, September 02, 2005 7:42 PM Subject: Re: How can I avoid unicode and use Latin1? (Was: Wrong characterswith jEdit) > Mats Bengtsson wrote: > > > If you find this added flexibility in LilyPond 2.6 so annoying, then > > you could use some program that converts a Latin1 coded file into > > UTF-8 coding and even make a script file that first does the > > conversion and then calls LilyPond. Unfortunately, I don't know > > Windows well enough to provide any specific hints but there should > > be several possibilities available. > > > > /Mats > > > This sounds like a job for a sed script, but... > > I offer the following with NO WARRANTY. I haven't used Windows in about > a year so this is all from memory, but 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 > (unless you have on-hand a guru who can improve this thing). Anyhow, > here goes. You'll want to save this with a ".vbs" extension. > > '==== 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 > lilypond-user@gnu.org > http://lists.gnu.org/mailman/listinfo/lilypond-user _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user