public override void FillBytesRef()
        {
            BytesRef bytes = BytesRef;
            var      utf16 = Charset.GetBytes(Charset.ToString());

            bytes.Bytes  = utf16;
            bytes.Offset = 0;
            bytes.Length = utf16.Length;
        }
        public override void FillBytesRef()
        {
            BytesRef bytes = BytesRef;

            sbyte[] utf16 = (sbyte[])(Array)Charset.GetBytes(Charset.ToString());
            bytes.Bytes  = utf16;
            bytes.Offset = 0;
            bytes.Length = utf16.Length;
        }
        public void DoFileConvert
        (
            string strConverterName,
            string strOutputFileName,
            System.Text.Encoding outEnc,
            string strInputFileName,
            System.Text.Encoding inEnc,
            bool bDirectionForward
        )
        {
#if VERBOSE_DEBUGGING
            Console.WriteLine("ECFileConv: DoFileConvert() BEGIN");
            Console.WriteLine("ECFileConv: inEnc " + inEnc.ToString());
#endif
            // the user *might* not give us a converter name if they simply want to change
            //  the encoding from, say, UTF8 to UTF16.
            bool bIsConverter = !(strConverterName == null);

            IEncConverter aEC = null;
            if (bIsConverter)
            {
#if VERBOSE_DEBUGGING
                Console.WriteLine("ECFileConv: Creating EncConverters object.");
#endif
                EncConverters aECs = new EncConverters();
#if VERBOSE_DEBUGGING
                Console.WriteLine("ECFileConv: Created EncConverters object.");
#endif
                if (strConverterName.ToLower() == "askme")
                {
#if VERBOSE_DEBUGGING
                    Console.WriteLine("ECFileConv: Calling AutoSelect.");
#endif
                    aEC = aECs.AutoSelect(ConvType.Unknown);
                    if (aEC == null)
                    {
                        // user probably pressed Cancel
                        Console.WriteLine("ECFileConv: No converter was selected.");
                        return;
                    }
                }
                else
                {
                    //// here's how you'd add the map programmatically (of course,
                    ////  update the path here
                    //string mapLoc = Path.Combine(GetProjectFolder, "ToUpper.tec");
                    //Console.WriteLine("mapLoc " + mapLoc);
                    //aECs.AddConversionMap(strConverterName, Path.Combine(GetProjectFolder, "ToUpper.tec"),
                    //    ConvType.Unicode_to_from_Unicode, EncConverters.strTypeSILtec,
                    //    "UNICODE", "UNICODE", ProcessTypeFlags.DontKnow);
                    //Console.WriteLine("Added map.");
                    aEC = aECs[strConverterName];    // e.g. "Devanagri<>Latin(ICU)"
                    if (aEC == null)
                    {
                        throw new ApplicationException(
                                  String.Format("The converter '{0}' wasn't in the repository. Did you forget to add it?",
                                                strConverterName));
                    }
                }
#if VERBOSE_DEBUGGING
                Console.WriteLine("ECFileConv: Got EncConverter.");
#endif
            }

            // open the input and output files using the given encoding formats
            StreamReader srReadLine = new StreamReader(strInputFileName, inEnc, true);
            srReadLine.BaseStream.Seek(0, SeekOrigin.Begin);
            StreamWriter swWriteLine = new StreamWriter(strOutputFileName, false, outEnc);

            // tell the converter to go the other way, if the user selected 'reverse'
            if (!bDirectionForward && bIsConverter)
            {
                aEC.DirectionForward = false;
            }

            // read the lines of the input file, (optionally convert,) and write them out.
            string sOutput, sInput;
            while (srReadLine.Peek() > -1)
            {
                sInput = srReadLine.ReadLine();

                if (bIsConverter)
                {
                    sOutput = aEC.Convert(sInput);
                }
                else
                {
                    sOutput = sInput;
                }

                swWriteLine.WriteLine(sOutput);
            }

            srReadLine.Close();
            swWriteLine.Close();
#if VERBOSE_DEBUGGING
            Console.WriteLine("ECFileConv: DoFileConvert END");
#endif
        }