UTF-16 to UTF-8 conversion (for scripting in Windows)
There is a GNU tool recode which you can also use on Windows. E.g.
recode utf16..utf8 text.txt
An alternative to Ruby would be to write a small .NET program in C# (.NET 1.0 would be fine, although 2.0 would be simpler :) - it's a pretty trivial bit of code. Were you hoping to do it without any other applications at all? If you want a bit of code to do it, add a comment and I'll fill in the answer...
EDIT: Okay, this is without any kind of error checking, but...
using System;
using System.IO;
using System.Text;
class FileConverter
{
static void Main(string[] args)
{
string inputFile = args[0];
string outputFile = args[1];
using (StreamReader reader = new StreamReader(inputFile, Encoding.Unicode))
{
using (StreamWriter writer = new StreamWriter(outputFile, false, Encoding.UTF8))
{
CopyContents(reader, writer);
}
}
}
static void CopyContents(TextReader input, TextWriter output)
{
char[] buffer = new char[8192];
int len;
while ((len = input.Read(buffer, 0, buffer.Length)) != 0)
{
output.Write(buffer, 0, len);
}
}
}