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


C# Encoding.Equals方法代码示例

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


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

示例1: IsTurkishLittleI

        public static bool IsTurkishLittleI(char firstLetter, Encoding encoding, string language)
        {
            if (language != "tr")
            {
                return false;
            }

            return encoding.Equals(Encoding.UTF8)
                ? firstLetter == 'ı' || firstLetter == 'i'
                : firstLetter == 'ý' || firstLetter == 'i';
        }
开发者ID:ItsJustSean,项目名称:subtitleedit,代码行数:11,代码来源:Helper.cs

示例2: GetEncodingInfo

        // 获得一个编码的信息。注意,本函数不能处理扩充的Marc8Encoding类
        static EncodingInfo GetEncodingInfo(Encoding encoding)
        {
            EncodingInfo [] infos = Encoding.GetEncodings();
            for (int i = 0; i < infos.Length; i++)
            {
                if (encoding.Equals(infos[i].GetEncoding()))
                    return infos[i];
            }


            return null;    // not found
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:13,代码来源:GetEncodingForm.cs

示例3: GetTurkishUppercaseLetter

 public static char GetTurkishUppercaseLetter(char letter, Encoding encoding)
 {
     if (encoding.Equals(Encoding.UTF8))
     {
         if (letter == 'ı')
             return 'I';
         if (letter == 'i')
             return 'İ';
     }
     else
     {
         if (letter == 'i')
             return 'Ý';
         if (letter == 'ý')
             return 'I';
     }
     return letter;
 }
开发者ID:ItsJustSean,项目名称:subtitleedit,代码行数:18,代码来源:Helper.cs

示例4: IsUnicode

 private bool IsUnicode(Encoding encoding)
 {
     return encoding.Equals(Encoding.UTF8) ||
         encoding.Equals(Encoding.Unicode) ||
         encoding.Equals(Encoding.BigEndianUnicode) ||
         encoding.Equals(Encoding.UTF7) ||
         encoding.Equals(Encoding.UTF32);
 }
开发者ID:kitsilanosoftware,项目名称:YamlDotNet,代码行数:8,代码来源:Emitter.cs

示例5: AppendMessage

		private static void AppendMessage(StringBuilder sb, string message, string format, Encoding encoding) {
			if(message == null)
				message = string.Empty;
			sb.Append("Content-Type: text/");
			sb.Append(format);
			if(StringHandler.IsAscii(message)) {
				sb.Append("\r\n");
				sb.Append("Content-Transfer-Encoding: 7Bit\r\n");
				sb.Append("\r\n");
				sb.Append(message);
			} else {
				if((encoding == null && !StringHandler.IsAnsi(message)) || (encoding != null && encoding.Equals(Encoding.UTF8))) {
					sb.Append("; charset=utf-8\r\n");
					sb.Append("Content-Transfer-Encoding: base64\r\n");
					sb.Append("\r\n");
					string base64String = Convert.ToBase64String(Encoding.UTF8.GetBytes(message));
					ChunkString(sb, base64String, 73);
				} else {
					if(encoding == null)
						encoding = Encoding.GetEncoding(1252);
					sb.Append("; charset=");
					sb.Append(encoding.BodyName);
					sb.Append("\r\n");
					sb.Append("Content-Transfer-Encoding: quoted-printable\r\n");
					sb.Append("\r\n");
					sb.Append(StringHandler.EncodeToQuotedPrintable(message, encoding));
				}
			}
			if(!message.EndsWith("\r\n"))
				sb.Append("\r\n");
			sb.Append("\r\n");
		}
开发者ID:aelveborn,项目名称:njupiter,代码行数:32,代码来源:Mail.cs

示例6: decodeNoFallback

        /**
         * Decode a region of the buffer under the specified character set if
         * possible.
         *
         * If the byte stream cannot be decoded that way, the platform default is
         * tried and if that too fails, an exception is thrown.
         *
         * @param cs
         *            character set to use when decoding the buffer.
         * @param buffer
         *            buffer to pull raw bytes from.
         * @param start
         *            first position within the buffer to take data from.
         * @param end
         *            one position past the last location within the buffer to take
         *            data from.
         * @return a string representation of the range <code>[start,end)</code>,
         *         After decoding the region through the specified character set.
         * @throws CharacterCodingException
         *             the input is not in any of the tested character sets.
         */
        internal static string decodeNoFallback(Encoding cs, byte[] buffer, int start, int end)
        {
            // ByteBuffer b = ByteBuffer.wrap(buffer, start, end - start);
            //b.mark();
            byte[] b = new byte[end - start];
            for (int i = 0; i < end - start; i++)
                b[i] = buffer[start + i];

              // Try our built-in favorite. The assumption here is that
                 // decoding will fail if the data is not actually encoded
                 // using that encoder.
                 //
                 try {
                         return decode(b, Constants.CHARSET);
                 } catch (DecoderFallbackException) {
                         //b.reset();
                 }

                 if (!cs.Equals(Constants.CHARSET)) {
                         // Try the suggested encoding, it might be right since it was
                         // provided by the caller.
                         //
                         try {
                                 return decode(b, cs);
                         } catch (DecoderFallbackException) {
                                 //b.reset();
                         }
                 }

                 // Try the default character set. A small group of people
                 // might actually use the same (or very similar) locale.
                 //
                 Encoding defcs = Encoding.Default;
                 if (!defcs.Equals(cs) && !defcs.Equals(Constants.CHARSET)) {
                         try {
                                 return decode(b, defcs);
                         }
                         catch (DecoderFallbackException)
                         {
                                 //b.reset();
                         }
                 }

                 throw new DecoderFallbackException(string.Format("Unable to decode provided buffer using encoder '{0}'.", cs.WebName) );
        }
开发者ID:virmitio,项目名称:DiffVHD,代码行数:66,代码来源:RawParseUtils.cs

示例7: Reset

        /// <summary>
        /// Simulates the insertion of the whole text, use this to reset the lines info 
        /// (when switching document for instance)
        /// </summary>
        internal void Reset()
        {
            _lastEncoding = Npp.Encoding;
            _oneByteCharEncoding = _lastEncoding.Equals(Encoding.Default);

            // bypass the hard work for simple encoding
            if (_oneByteCharEncoding)
                return;

            _linesList = new GapBuffer<int> { 0, 0 };
            var scn = new SCNotification {
                linesAdded = SciGetLineCount() - 1,
                position = 0,
                length = SciGetLength()
            };
            scn.text = Npp.Sci.Send(SciMsg.SCI_GETRANGEPOINTER, new IntPtr(scn.position), new IntPtr(scn.length));
            OnInsertedText(scn);
        }
开发者ID:jcaillon,项目名称:3P,代码行数:22,代码来源:DocumentLines.cs

示例8: OnScnModified

        /// <summary>
        /// When receiving a modification notification by scintilla
        /// </summary>
        public void OnScnModified(SCNotification scn, bool isInsertion)
        {
            _lastEncoding = Npp.Encoding;
            _oneByteCharEncoding = _lastEncoding.Equals(Encoding.Default);

            // bypass the hard work for simple encoding
            if (_oneByteCharEncoding)
                return;

            if (isInsertion) {
                OnInsertedText(scn);
            } else {
                OnDeletedText(scn);
            }
        }
开发者ID:jcaillon,项目名称:3P,代码行数:18,代码来源:DocumentLines.cs

示例9: setEncoding

        /**
         * Toggles the encoding between Ascii and Binary
         * Sends TYPE A over the command line for Ascii
         * Sends TYPE I over command line for binary
         */
        public void setEncoding(Encoding enc)
        {
            string toSend = enc.Equals(Encoding.Ascii) ? "A" : "I";

            if (debug)
            {
                Console.WriteLine("DEBUG:::: Sending 'TYPE " + toSend + "'");
            }
            sendOverLine(CommandInput.TYPE + " " + toSend);
        }
开发者ID:ross-kahn,项目名称:ftp,代码行数:15,代码来源:Connection.cs


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