当前位置: 首页>>代码示例>>C#>>正文


C# UTF8Encoding.GetDecoder方法代码示例

本文整理汇总了C#中System.Text.UTF8Encoding.GetDecoder方法的典型用法代码示例。如果您正苦于以下问题:C# UTF8Encoding.GetDecoder方法的具体用法?C# UTF8Encoding.GetDecoder怎么用?C# UTF8Encoding.GetDecoder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Text.UTF8Encoding的用法示例。


在下文中一共展示了UTF8Encoding.GetDecoder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: decryptPassword1

    public static string decryptPassword1(string sData)
    {
        string result = "";
        try
        {
            System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();

            System.Text.Decoder utf8Decode = encoder.GetDecoder();

            byte[] todecode_byte = Convert.FromBase64String(sData);

            int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);

            char[] decoded_char = new char[charCount];

            utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);

            result = new string(decoded_char);

        }
        catch
        {

        }
        return result;
    }
开发者ID:rintujrajan,项目名称:SchoolERP_A,代码行数:26,代码来源:Helper.cs

示例2: DecodeBase64

        /// <summary>
        /// Decodeaza textul din base 64
        /// </summary>
        /// <param name="text">Textul</param>
        /// <param name="deviation">Adevarat daca textul este deviat</param>
        /// <returns></returns>
        public static string DecodeBase64(string text, bool deviation)
        {
            try
            {
                var encoder = new UTF8Encoding();
                Decoder utf8Decode = encoder.GetDecoder();

                if (deviation)
                {
                    // lungimea initiala a textului codat (dupa %)
                    int initialLength;
                    int indexOf = text.LastIndexOf('%');
                    int.TryParse(text.Substring(indexOf + 1), out initialLength);
                    text = Deviate(text.Substring(0, indexOf), -initialLength);
                }

                byte[] todecode_byte = Convert.FromBase64String(text);
                int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
                char[] decoded_char = new char[charCount];
                utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
                string result = new String(decoded_char);
                return result;
            }
            catch (Exception)
            {
                return "";
            }
        }
开发者ID:timotei,项目名称:InfoCenter,代码行数:34,代码来源:Encoding.cs

示例3: Decryptdata

        public string Decryptdata(string imagepath)
        {
            string image = "";
            if (imagepath != "")
            {
                string[] path = { "" };
                path = imagepath.Split('/');
                string baseurl = path[0];
                string filename = path[1];
                string[] withextention = { "" };
                withextention = filename.Split('.');
                string encryptpwd = withextention[0];
                string extention = withextention[1];
                string decryptpwd = string.Empty;
                UTF8Encoding encodepwd = new UTF8Encoding();
                Decoder Decode = encodepwd.GetDecoder();
                byte[] todecode_byte = Convert.FromBase64String(encryptpwd);
                int charCount = Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
                char[] decoded_char = new char[charCount];
                Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
                decryptpwd = new String(decoded_char);

                image = baseurl + "/" + decryptpwd + "." + extention;
            }
            else
            {
                image = "~/Users/Images/Chrysanthemum.jpg";
            }
            return image;
        }
开发者ID:jasimuddin534,项目名称:jasim_basis,代码行数:30,代码来源:Users.aspx.cs

示例4: SubstituteArabicDigits

        /// <summary>
        /// based on http://weblogs.asp.net/abdullaabdelhaq/archive/2009/06/27/displaying-arabic-number.aspx
        /// seems like a fairly expensive method to call so not sure if its suitable to use this everywhere
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static string SubstituteArabicDigits(string input)
        {
            if (string.IsNullOrEmpty(input)) { return input; }

            Encoding utf8 = new UTF8Encoding();
            Decoder utf8Decoder = utf8.GetDecoder();
            StringBuilder result = new StringBuilder();

            Char[] translatedChars = new Char[1];
            Char[] inputChars = input.ToCharArray();
            Byte[] bytes = { 217, 160 };

            foreach (Char c in inputChars)
            {
                if (Char.IsDigit(c))
                {
                    // is this the key to it all? does adding 160 change to the unicode char for Arabic?
                    //So we can do the same with other languages using a different offset?
                    bytes[1] = Convert.ToByte(160 + Convert.ToInt32(char.GetNumericValue(c)));
                    utf8Decoder.GetChars(bytes, 0, 2, translatedChars, 0);
                    result.Append(translatedChars[0]);
                }
                else
                {
                    result.Append(c);
                }
            }

            return result.ToString();
        }
开发者ID:saiesh86,项目名称:TravelBlog,代码行数:36,代码来源:CultureHelper.cs

示例5: base64Decode

        public static string base64Decode(string sData)
        {
            try
            {

                System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();

                System.Text.Decoder utf8Decode = encoder.GetDecoder();

                byte[] todecode_byte = Convert.FromBase64String(sData);

                int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);

                char[] decoded_char = new char[charCount];

                utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);

                string result = new String(decoded_char);

                return result;
            }
            catch (Exception ex)
            {
                throw new Exception("Error in base64Decode" + ex.Message);
            }
        }
开发者ID:manivts,项目名称:impexcubeapp,代码行数:26,代码来源:EcnryptionTest.cs

示例6: ConvertToArabicNumerals

        private string ConvertToArabicNumerals(string input)
        {
            UTF8Encoding utf8Encoder = new UTF8Encoding();
            Decoder utf8Decoder = utf8Encoder.GetDecoder();
            StringBuilder convertedChars = new System.Text.StringBuilder();
            char[] convertedChar = new char[1];
            byte[] bytes = new byte[] { 217, 160 };
            char[] inputCharArray = input.ToCharArray();

            foreach (char c in inputCharArray)
            {
                if (char.IsDigit(c))
                {
                    bytes[1] = System.Convert.ToByte(160 + char.GetNumericValue(c));
                    utf8Decoder.GetChars(bytes, 0, 2, convertedChar, 0);
                    convertedChars.Append(convertedChar[0]);
                }
                else
                {
                    convertedChars.Append(c);
                }
            }

            return convertedChars.ToString();
        }
开发者ID:CubeFramework,项目名称:Platform,代码行数:25,代码来源:LocalisedNumberConverter.cs

示例7: Decode

        public static string Decode( string data )
        {
            UTF8Encoding encoder = new UTF8Encoding( );
            Decoder utf8Decode = encoder.GetDecoder( );

            byte[ ] todecode_byte = Convert.FromBase64String( data );

            return Decode( todecode_byte );
        }
开发者ID:CriGoT,项目名称:pop3dotnet,代码行数:9,代码来源:Base64EncodingHelper.cs

示例8: DecodeBase64String

 public static string DecodeBase64String(string encodedString)
 {
     byte[] bytes = Convert.FromBase64String(encodedString);
     var encoder = new UTF8Encoding();
     Decoder decoder = encoder.GetDecoder();
     int charCount = decoder.GetCharCount(bytes, 0, bytes.Length);
     var decodedMessage = new char[charCount];
     decoder.GetChars(bytes, 0, bytes.Length, decodedMessage, 0);
     return new string(decodedMessage);
 }
开发者ID:zinark,项目名称:imapClient,代码行数:10,代码来源:StringDecoder.cs

示例9: Page_Load

    /// <summary>
    /// Event, that triggers when the application page is loaded into the web browser
    /// Listens to server and stores the mms messages in server
    /// </summary>
    /// <param name="sender">object, that caused this event</param>
    /// <param name="e">Event that invoked this function</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        FileStream fileStream = null;
        try
        {
            Random random = new Random();
            DateTime currentServerTime = DateTime.UtcNow;

            string receivedTime = currentServerTime.ToString("HH-MM-SS");
            string receivedDate = currentServerTime.ToString("MM-dd-yyyy");

            string inputStreamContents;
            int stringLength;
            int strRead;

            Stream stream = Request.InputStream;
            stringLength = Convert.ToInt32(stream.Length);

            byte[] stringArray = new byte[stringLength];
            strRead = stream.Read(stringArray, 0, stringLength);
            inputStreamContents = System.Text.Encoding.UTF8.GetString(stringArray);

            string[] splitData = Regex.Split(inputStreamContents, "</SenderAddress>");
            string data = splitData[0].ToString();
            string senderAddress = inputStreamContents.Substring(data.IndexOf("tel:") + 4, data.Length - (data.IndexOf("tel:") + 4));
            string[] parts = Regex.Split(inputStreamContents, "--Nokia-mm-messageHandler-BoUnDaRy");
            string[] lowerParts = Regex.Split(parts[2], "BASE64");
            string[] imageType = Regex.Split(lowerParts[0], "image/");
            int indexOfSemicolon = imageType[1].IndexOf(";");
            string type = imageType[1].Substring(0, indexOfSemicolon);
            UTF8Encoding encoder = new System.Text.UTF8Encoding();
            Decoder utf8Decode = encoder.GetDecoder();

            byte[] todecode_byte = Convert.FromBase64String(lowerParts[1]);

            if (!Directory.Exists(Request.MapPath(ConfigurationManager.AppSettings["ImageDirectory"])))
            {
                Directory.CreateDirectory(Request.MapPath(ConfigurationManager.AppSettings["ImageDirectory"]));
            }

            string fileNameToSave = "From_" + senderAddress.Replace("+","") + "_At_" + receivedTime + "_UTC_On_" + receivedDate + random.Next();
            fileStream = new FileStream(Request.MapPath(ConfigurationManager.AppSettings["ImageDirectory"]) + fileNameToSave + "." + type, FileMode.CreateNew, FileAccess.Write);
            fileStream.Write(todecode_byte, 0, todecode_byte.Length);
        }
        catch
        { }
        finally
        {
            if (null != fileStream)
            {
                fileStream.Close();
            }
        }
    }
开发者ID:attdevsupport,项目名称:API-Platform,代码行数:60,代码来源:Listener.aspx.cs

示例10: DecodeFrom64

 public static string DecodeFrom64(string encodedData)
 {
     System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
     System.Text.Decoder utf8Decode = encoder.GetDecoder();
     byte[] todecode_byte = Convert.FromBase64String(encodedData);
     int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
     char[] decoded_char = new char[charCount];
     utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
     string result = new String(decoded_char);
     return result;
 }
开发者ID:RaghavaK1989Bng,项目名称:IYCDashboard,代码行数:11,代码来源:PasswordEncDec.cs

示例11: base64Decode

        String base64Decode(String data)
        {
            UTF8Encoding encoder = new System.Text.UTF8Encoding();
            Decoder utf8Decode = encoder.GetDecoder();

            Byte[] todecode_byte = Convert.FromBase64String(data);
            int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
            Char[] decoded_char = new Char[charCount];
            utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
            String result = new String(decoded_char);
            return result;
        }
开发者ID:GNCPay,项目名称:core,代码行数:12,代码来源:XPay.cs

示例12: Decode

        public static string Decode( byte[ ] todecode_byte )
        {
            UTF8Encoding encoder = new UTF8Encoding( );
            Decoder utf8Decode = encoder.GetDecoder( );

            int charCount = utf8Decode.GetCharCount( todecode_byte, 0, todecode_byte.Length );

            char[ ] decoded_char = new char[ charCount ];
            utf8Decode.GetChars( todecode_byte, 0, todecode_byte.Length, decoded_char, 0 );

            return new String( decoded_char );
        }
开发者ID:sasha237,项目名称:NorthCitadel,代码行数:12,代码来源:Base64EncodingHelper.cs

示例13: Decryptdata

 private string Decryptdata(string encryptpwd)
 {
     string decryptpwd = string.Empty;
     UTF8Encoding encodepwd = new UTF8Encoding();
     Decoder Decode = encodepwd.GetDecoder();
     byte[] todecode_byte = Convert.FromBase64String(encryptpwd);
     int charCount = Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
     char[] decoded_char = new char[charCount];
     Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
     decryptpwd = new String(decoded_char);
     return decryptpwd;
 }
开发者ID:kamaelyoung,项目名称:HR.bizstrides,代码行数:12,代码来源:encryptpwd.aspx.cs

示例14: Base64Decode

        public void Base64Decode()
        {
            var encoder = new System.Text.UTF8Encoding();
            var utf8Decode = encoder.GetDecoder();

            byte[] cadenaByte = Convert.FromBase64String(this.contenido);
            int charCount = utf8Decode.GetCharCount(cadenaByte, 0, cadenaByte.Length);
            char[] decodedChar = new char[charCount];
            utf8Decode.GetChars(cadenaByte, 0, cadenaByte.Length, decodedChar, 0);
            string result = new String(decodedChar);
            this.contenido = result;
        }
开发者ID:tjsearsz,项目名称:MINESANTED,代码行数:12,代码来源:Diseño.cs

示例15: Url_Decodificada

    public string Url_Decodificada(string cadena)
    {
        var encoder = new System.Text.UTF8Encoding();
        var utf8Decode = encoder.GetDecoder();

        byte[] cadenaByte = Convert.FromBase64String(cadena);
        int charCount = utf8Decode.GetCharCount(cadenaByte, 0, cadenaByte.Length);
        char[] decodedChar = new char[charCount];
        utf8Decode.GetChars(cadenaByte, 0, cadenaByte.Length, decodedChar, 0);
        string result = new String(decodedChar);
        return result;
    }
开发者ID:alejandroEGT,项目名称:babysitter,代码行数:12,代码来源:PerfilNiñera.aspx.cs


注:本文中的System.Text.UTF8Encoding.GetDecoder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。