• MisLead (4/23/2012)


    I have no knowledge on c#. However i have the following code below that converts double byte to unicode. My requirement is reverse engineering i.e convert unicode (non english characters) to double byte ANSI.I have no idea what changes I should make to achieve that.Please help. thanks.

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Runtime.InteropServices;

    using System.ComponentModel;

    using System.Data.SqlTypes;

    namespace ConvertToUnicode

    {

    public static class ConvertStringToUnicode

    {

    public static string ConvertToUnicode(int codePage, SqlString input)

    {

    string output;

    Encoding srcEncoding = Encoding.GetEncoding(codePage);

    byte[] byteInput = input.GetNonUnicodeBytes();

    byte[] byteOutput =UnicodeEncoding.Convert(srcEncoding, Encoding.Unicode, byteInput);

    output = Encoding.Unicode.GetString(byteOutput);

    return output;

    }

    }

    }

    Not enough info...

    What you posted is presumably from a standard C# class...not necessarily a SQLCLR object.

    What is your goal? To create a SQLCLR function that does the same thing?

    What do you mean by "double byte ANSI"? UCS-2, i.e. Windows version of "Unicode"? Or Windows 1252 stored in double-byte format? What is the desired destination code page?

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato