Default collation used for string exchanges with server. (always use utf8)

@param serverLanguage server default collation
@return collation byte
542748
private byte decideLanguage(int serverLanguage) {
    //force UTF8mb4 if possible, UTF8 if not.
    if (serverLanguage == 45        //utf8mb4_general_ci
        || serverLanguage == 46 //utf8mb4_bin
        || (serverLanguage >= 224 && serverLanguage <= 247)) {
      return (byte) serverLanguage;
    } else if (serverLanguage == 33        //utf8_general_ci
        || serverLanguage == 83 //utf8_bin
        || serverLanguage == 223 //utf8_general_mysql500_ci
        || (serverLanguage >= 192 && serverLanguage <= 215)) {
      return (byte) serverLanguage;
    }
    if (getMajorServerVersion() == 5 && getMinorServerVersion() <= 1) {
      return (byte) 33; //utf8_general_ci
    }
    return (byte) 224; //UTF8MB4_UNICODE_CI;

  }
590080
def _compile_create_encoding(self, sql, connection, blueprint):
        
        charset = blueprint.charset or connection.get_config("charset")
        if charset:
            sql += " DEFAULT CHARACTER SET %s" % charset

        collation = blueprint.collation or connection.get_config("collation")
        if collation:
            sql += " COLLATE %s" % collation

        return sql
427411
public static String getUS7ASCIIEquiv(String convertString) {
    if (convertString == null)
      return null;

    StringBuilder convertedString = new StringBuilder();
    String upperConvertString = convertString.toUpperCase();

    Collator collator = Collator.getInstance(Locale.US);
    collator.setStrength(Collator.PRIMARY);

    String chars = "abcdefghijklmnopqrstuvwxyz";
    for (int i = 0; i < convertString.length(); i++) {
      char currentChar = convertString.charAt(i);
      boolean isUppercase = currentChar == upperConvertString.charAt(i);
      char mappedChar = ' ';
      if (currentChar < 128) {
        // Within low-ascii, leave it alone.
        mappedChar = currentChar;
      } else if (currentChar < 256) {
        for (int j = 0; j < chars.length(); j++) {
          if (collator.compare(currentChar + "", chars.charAt(j) + "") == 0) {
            if (isUppercase)
              mappedChar = Character.toUpperCase(chars.charAt(j));
            else
              mappedChar = chars.charAt(j);
            break;
          }
        }
      } else {
        // Out of our mapping range. It just becomes a space
      }
      convertedString.append(mappedChar);
    }
    return convertedString.toString();
  }
435384
public static UTF8String fromAddress(Object base, long offset, int numBytes) {
    return new UTF8String(base, offset, numBytes);
  }
78479
public static Locale fromString(final String locale) {
        final String[] data = Strings.split(locale, '_');
        if (data.length == 1) {
            return new Locale(data[0]);
        } else if (data.length == 2) {
            return new Locale(data[0], data[1]);
        } else if (data.length == 3) {
            return new Locale(data[0], data[1], data[2]);
        }
        throw new IllegalArgumentException("Invalid locale string: " + locale);
    }
97313
public static ByteBuffer fromUtf8String(CharSequence utfString) {
        if (utfString == null || utfString.length() == 0) {
            return Buffers.EMPTY_BYTE_BUFFER;
        } else {
            return ByteBuffer.wrap(utfString.toString().getBytes(StandardCharsets.UTF_8));
        }
    }
1088908
public static Vector processAcceptLanguage(String acceptLanguage) {
    	init();
        StringTokenizer languageTokenizer = new StringTokenizer(acceptLanguage, ",");
        TreeMap map = new TreeMap(Collections.reverseOrder());

        while (languageTokenizer.hasMoreTokens()) {
            String language = languageTokenizer.nextToken().trim();
            /* begin pq57399: part 1 */
            if (language == null || language.length() == 0) {
                if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {
                    logger.logp(Level.FINE, CLASS_NAME,"processAcceptLanguage", "Encountered zero length language token without quality index.. skipping token");
                    logger.logp(Level.FINE, CLASS_NAME,"processAcceptLanguage", "acceptLanguage param = [" + acceptLanguage + "]");
                }
                continue;
            }
            /* end pq57399: part 1 */

            int semicolonIndex = language.indexOf(';');
            Double qValue = new Double(1);

            if (semicolonIndex > -1) {
                int qIndex = language.indexOf("q=");
                String qValueStr = language.substring(qIndex + 2);
                try {
                    qValue = new Double(qValueStr.trim());
                }
                catch (NumberFormatException nfe) {
                    com.ibm.wsspi.webcontainer.util.FFDCWrapper.processException(nfe, "com.ibm.ws.webcontainer.srt.SRTRequestUtils.processAcceptLanguage", "215");
                }
                language = language.substring(0, semicolonIndex);
            }
            if (language.length() > 0) { /* added for pq57399: part 2*/
                if ((qValue.doubleValue() > 0) && (language.charAt(0) != '*')) {
                    Vector newVector = new Vector();
                    if (map.containsKey(qValue)) {
                        newVector = (Vector) map.get(qValue);
                    }
                    newVector.addElement(language);
                    map.put(qValue, newVector);
                } /* begin pq57399: part 3 */

            }
            else {
                if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {
                    logger.logp(Level.FINE, CLASS_NAME,"processAcceptLanguage", "Encountered zero length language token with quality index.. skipping token");
                    logger.logp(Level.FINE, CLASS_NAME,"processAcceptLanguage", "acceptLanguage param = [" + acceptLanguage + "]");
                }

            } /* end pq57399: part 3 */

        }

        if (map.isEmpty()) {
            Vector v = new Vector();
            v.addElement(Locale.getDefault().toString());
            map.put("1", v);
        }
        return new Vector(map.values());
    }
475871
def get_charset(message, default='ASCII'):
    """"""

    charset = message.get_content_charset()

    if not charset:
        charset = message.get_charset()

    if not charset:
        charset = default

    try:
        codecs.lookup(charset)
    except LookupError:
        charset = default

    return charset
974292
def get_charset(message, default="utf-8"):
    """"""
    if message.get_content_charset():
        return message.get_content_charset()
    if message.get_charset():
        return message.get_charset()
    return default
319901
public Translation get(String locale) {
        locale = locale.replace("-", "_");
        Translation tr = translations.get(locale);
        if (locale.contains("_") && tr == null)
            tr = translations.get(locale.substring(0, 2));

        return tr;
    }
144109
public UTF8String toUpperCase() {
    if (numBytes == 0) {
      return EMPTY_UTF8;
    }

    byte[] bytes = new byte[numBytes];
    bytes[0] = (byte) Character.toTitleCase(getByte(0));
    for (int i = 0; i < numBytes; i++) {
      byte b = getByte(i);
      if (numBytesForFirstByte(b) != 1) {
        // fallback
        return toUpperCaseSlow();
      }
      int upper = Character.toUpperCase((int) b);
      if (upper > 127) {
        // fallback
        return toUpperCaseSlow();
      }
      bytes[i] = (byte) upper;
    }
    return fromBytes(bytes);
  }
1176626
@Override
    public String getEncodingFromLocale(Locale locale) {
        if (null == locale) {
            return null;
        }
        if (locale.equals(this.cachedLocale)) {
            return this.cachedEncoding;
        }

        String encoding = localeMap.get(locale.toString());
        if (null == encoding) {
            final String lang = locale.getLanguage();
            encoding = localeMap.get(lang + '_' + locale.getCountry());
            if (null == encoding) {
                encoding = localeMap.get(lang);
            }
        }

        this.cachedEncoding = encoding;
        this.cachedLocale = locale;

        return encoding;
    }
336001
public UTF8String toLowerCase() {
    if (numBytes == 0) {
      return EMPTY_UTF8;
    }

    byte[] bytes = new byte[numBytes];
    bytes[0] = (byte) Character.toTitleCase(getByte(0));
    for (int i = 0; i < numBytes; i++) {
      byte b = getByte(i);
      if (numBytesForFirstByte(b) != 1) {
        // fallback
        return toLowerCaseSlow();
      }
      int lower = Character.toLowerCase((int) b);
      if (lower > 127) {
        // fallback
        return toLowerCaseSlow();
      }
      bytes[i] = (byte) lower;
    }
    return fromBytes(bytes);
  }
943354
public static String getCharset(HttpEntity entity) {
		final String guess = EntityUtils.getContentCharSet(entity);
		return guess == null ? HTTP.DEFAULT_CONTENT_CHARSET : guess;
	}
1335908
def utf8(string):
    
    if isinstance(string, six.text_type):
        return string.encode('utf8')
    elif isinstance(string, six.binary_type):
        return string
    else:
        return six.text_type(string).encode('utf8')
238537
public static String getCurrencySymbol(Locale locale, String currencyCode) {
    return getCurrencySymbol(locale.toLanguageTag(), currencyCode);
  }
775991
public static Function<String, String> toUpperCase(@Nonnull Locale locale) {
        return new ToUpperCaseFunction(checkNotNull(locale));
    }