public static GetCharacterSet ( MySql.Data.Common.DBVersion version, string CharSetName ) : |
||
version | MySql.Data.Common.DBVersion | |
CharSetName | string | |
return |
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]); }
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]); }
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]); }
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); }
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); }
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]); }