System.IO.Compression.ZipHelper.RequiresUnicode C# (CSharp) Méthode

RequiresUnicode() static private méthode

static private RequiresUnicode ( string test ) : bool
test string
Résultat bool
        internal static bool RequiresUnicode(string test)
        {
            Debug.Assert(test != null);

            foreach (char c in test)
            {
                // The Zip Format uses code page 437 when the Unicode bit is not set. This format
                // is the same as ASCII for characters 32-126 but differs otherwise. If we can fit 
                // the string into CP437 then we treat ASCII as acceptable.
                if (c > 126 || c < 32)
                    return true;
            }

            return false;
        }

Usage Example

Exemple #1
0
        private byte[] EncodeEntryName(string entryName, out bool isUTF8)
        {
            Encoding entryNameEncoding;

            if (this._archive == null || this._archive.EntryNameEncoding == null)
            {
                entryNameEncoding = (ZipHelper.RequiresUnicode(entryName) ? Encoding.UTF8 : Encoding.GetEncoding(0));
            }
            else
            {
                entryNameEncoding = this._archive.EntryNameEncoding;
            }
            isUTF8 = (!(entryNameEncoding is UTF8Encoding) ? false : entryNameEncoding.Equals(Encoding.UTF8));
            return(entryNameEncoding.GetBytes(entryName));
        }
All Usage Examples Of System.IO.Compression.ZipHelper::RequiresUnicode