GetCharacterSet() public static method

public static GetCharacterSet ( MySql.Data.Common.DBVersion version, string CharSetName ) : CharacterSet
version MySql.Data.Common.DBVersion
CharSetName string
return CharacterSet
コード例 #1
0
        private void SetFieldEncoding()
        {
            Dictionary <int, string> characterSets = this.driver.CharacterSets;
            DBVersion version = this.driver.Version;

            if (characterSets == null || characterSets.Count == 0 || this.CharacterSetIndex == -1)
            {
                return;
            }
            if (characterSets[this.CharacterSetIndex] == null)
            {
                return;
            }
            CharacterSet characterSet = CharSetMap.GetCharacterSet(version, characterSets[this.CharacterSetIndex]);

            if (characterSet.name.ToLower(CultureInfo.InvariantCulture) == "utf-8" && version.Major >= 6)
            {
                this.MaxLength = 4;
            }
            else
            {
                this.MaxLength = characterSet.byteCount;
            }
            this.Encoding = CharSetMap.GetEncoding(version, characterSets[this.CharacterSetIndex]);
        }
コード例 #2
0
        private void SetFieldEncoding()
        {
            Hashtable charSets = driver.CharacterSets;
            DBVersion version  = driver.Version;

            if (charSets == null || CharacterSetIndex == -1)
            {
                return;
            }
            if (charSets[CharacterSetIndex] == null)
            {
                return;
            }

            CharacterSet cs = CharSetMap.GetCharacterSet(version, (string)charSets[CharacterSetIndex]);

            // starting with 6.0.4 utf8 has a maxlen of 4 instead of 3.  The old
            // 3 byte utf8 is utf8mb3
            if (cs.name.ToLower(System.Globalization.CultureInfo.InvariantCulture) == "utf-8" &&
                version.Major >= 6)
            {
                MaxLength = 4;
            }
            else
            {
                MaxLength = cs.byteCount;
            }
            Encoding = CharSetMap.GetEncoding(version, (string)charSets[CharacterSetIndex]);
        }
コード例 #3
0
ファイル: Field.cs プロジェクト: webmotors/Mysql.Data.Core
        private void SetFieldEncoding()
        {
            Dictionary <int, string> charSets = driver.CharacterSets;
            DBVersion version = driver.Version;

            if (charSets == null || charSets.Count == 0 || CharacterSetIndex == -1)
            {
                return;
            }
            if (charSets[CharacterSetIndex] == null)
            {
                return;
            }

            CharacterSet cs = CharSetMap.GetCharacterSet(version, (string)charSets[CharacterSetIndex]);

            // starting with 6.0.4 utf8 has a maxlen of 4 instead of 3.  The old
            // 3 byte utf8 is utf8mb3
            if (cs.name.ToLowerInvariant() == "utf-8" &&
                version.Major >= 6)
            {
                MaxLength = 4;
            }
            else
            {
                MaxLength = cs.byteCount;
            }
            Encoding = CharSetMap.GetEncoding(version, (string)charSets[CharacterSetIndex]);
        }
コード例 #4
0
        private MySqlField GetFieldMetaData41()
        {
            MySqlField field = new MySqlField(connection);

            stream.OpenPacket();
            field.Encoding           = encoding;
            field.CatalogName        = stream.ReadLenString();
            field.DatabaseName       = stream.ReadLenString();
            field.TableName          = stream.ReadLenString();
            field.RealTableName      = stream.ReadLenString();
            field.ColumnName         = stream.ReadLenString();
            field.OriginalColumnName = stream.ReadLenString();
            stream.ReadByte();
            field.CharacterSetIndex = stream.ReadInteger(2);
            field.ColumnLength      = stream.ReadInteger(4);
            MySqlDbType type = (MySqlDbType)stream.ReadByte();
            ColumnFlags colFlags;

            if ((Flags & ClientFlags.LONG_FLAG) != 0)
            {
                colFlags = (ColumnFlags)stream.ReadInteger(2);
            }
            else
            {
                colFlags = (ColumnFlags)stream.ReadByte();
            }

            field.SetTypeAndFlags(type, colFlags);

            field.Scale = (byte)stream.ReadByte();


            if (stream.HasMoreData)
            {
                stream.ReadInteger(2); // reserved
            }

            if (charSets != null && field.CharacterSetIndex != -1)
            {
                CharacterSet cs = CharSetMap.GetCharacterSet(Version, (string)charSets[field.CharacterSetIndex]);
                // starting with 6.0.4 utf8 has a maxlen of 4 instead of 3.  The old
                // 3 byte utf8 is utf8mb3
                if (cs.name.ToLower(System.Globalization.CultureInfo.InvariantCulture) == "utf-8" &&
                    Version.Major >= 6)
                {
                    field.MaxLength = 4;
                }
                else
                {
                    field.MaxLength = cs.byteCount;
                }
                field.Encoding = CharSetMap.GetEncoding(version, (string)charSets[field.CharacterSetIndex]);
            }

            return(field);
        }
コード例 #5
0
        public static Encoding GetEncoding(DBVersion version, string CharSetName)
        {
            Encoding encoding;

            try
            {
                encoding = Encoding.GetEncoding(CharSetMap.GetCharacterSet(version, CharSetName).name);
            }
            catch (NotSupportedException)
            {
                encoding = Encoding.GetEncoding("gbk");
            }
            return(encoding);
        }
コード例 #6
0
        private void SetFieldEncoding()
        {
            Dictionary <int, string> charSets = driver.CharacterSets;
            DBVersion version = driver.Version;

            if (charSets == null || charSets.Count == 0 || CharacterSetIndex == -1)
            {
                return;
            }
            if (charSets[CharacterSetIndex] == null)
            {
                return;
            }

            CharacterSet cs = CharSetMap.GetCharacterSet(version, (string)charSets[CharacterSetIndex]);

            MaxLength = cs.byteCount;
            Encoding  = CharSetMap.GetEncoding(version, (string)charSets[CharacterSetIndex]);
        }