Sanitize the value of an LC variable removing any character
encoding portion, such that en_GB.UTF-8 becomes en_gb.

@param lang A language identifier extracted from an LC variable.
@param filter A filter function.

@return A sanitized language identifier.
425400
function sanitize(lang, filter) {
  if(!(typeof lang == 'string')) return lang;
  lang = lang.replace(/\..*$/, '').toLowerCase();
  if(typeof filter == 'function') {
    lang = filter(lang);
  }
  return lang;
}
938359
function normaliseLanguageCode(lang) {
    	    lang = lang.toLowerCase();
    	    if (lang.length > 3) {
    		lang = lang.substring(0, 3) + lang.substring(3).toUpperCase();
    	    }
    	    return lang;
    	}
709667
public static String sanitizeCategory(String category) {
        String res = null;
        if (StringUtils.isNotBlank(category)) {
            res = category.trim().replaceAll("[^" + CATEGORYNAME_CHARS + "]", "");
            if (!res.equals(category)) LOG.error("Invalid characters in category {}", category);
        }
        return res;
    }
1274300
function sanitize (val) {
  if (typeof val !== 'string') {
    return '';
  }
  val = val.replace(/&/g,'&amp;');
  val = val.replace(/"/g,'&quot;');
  val = val.replace(/'/g,'&#039;');
  val = val.replace(/</g,'&lt;');
  val = val.replace(/>/g,'&gt;');
  val = val.replace(/\n/g,'<br />');
  return val ;
}
654111
private static String getLanguageSuffix(String language) {

        if (language.equals(Locale.JAPANESE.getLanguage())) {
            return "jp";
        } else {
            return language;
        }
    }
1113854
private static function determineTokenType($filter)
	{
		if (in_array(substr($filter, 0, 2), array_keys(self::$supported_tokens))) {
			// Two character token (<=, >=, etc)
			return substr($filter, 0, 2);
		} elseif (in_array($filter[0], array_keys(self::$supported_tokens))) {
			// Single character token (>, ^, $)
			return $filter[0];
		}

		// No token
		return false;
	}
1079864
private function getFilterOperator($filter)
    {
        $operator = str_replace('notlike', 'not like', $filter);
        $operator = str_replace('gt', '>', $operator);
        $operator = str_replace('ge', '>=', $operator);
        $operator = str_replace('lt', '<', $operator);
        $operator = str_replace('le', '<=', $operator);
        $operator = str_replace('eq', '=', $operator);
        $operator = str_replace('ne', '!=', $operator);

        return $operator;
    }
559465
public static SanitizedContent filterSipUri(SoyValue value) {
    value = normalizeNull(value);
    return filterSipUri(value.coerceToString());
  }
906766
public static String sanitize(String s) {
        if (s != null) {
            StringBuilder b = new StringBuilder(s.length());
            for (int i = 0, count = s.length(); i < count; i++) {
                char c = s.charAt(i);
                switch (c) {
                case '<':
                    b.append("&lt;");
                    break;
                case '>':
                    b.append("&gt;");
                    break;
                case '\'':
                    b.append("&#39;");
                    break;
                case '"':
                    b.append("&quot;");
                    break;
                case '&':
                    b.append("&amp;");
                    break;
                default:
                    b.append(c);
                }
            }
            return b.toString();
        }
        return "";
    }
630481
public String getLang(final Locale locale, final String key) {
        return langs.get(locale.toString()).getProperty(key);
    }
631009
@Override
    public FastStr toUpperCase(Locale locale) {
        String s = toString();
        return unsafeOf(s.toUpperCase(locale));
    }
1020564
private static String toLanguageTag(String locale) {
        if (locale == null) {
            return null;
        }
        // assume we are already a language tag
        if (!locale.contains("_")) {
            return locale;
        }

        // language can be missing, in which case we don't even bother
        if (locale.startsWith("_")) {
            return locale;
        }

        // Java 6 does "lang_country_variant". If country is missing, then "lang__variant". If no
        // variant, then just "lang_country".
        String [] parts = locale.split("_", 3);

        String lang = parts[0];
        String country = parts[1];
        String variant = parts.length == 3 ? parts[2] : "";

        return toLanguageTag(new Locale(lang, country, variant));
    }
290394
def sanitize_filterrific_param(val)
      case val
      when Array
        # Return Array
        val.map { |e| sanitize_filterrific_param(e) }
      when Hash
        # Return Hash
        val.inject({}) { |m, (k,v)| m[k] = sanitize_filterrific_param(v); m }
      when NilClass
        # Nothing to do, use val as is
        val
      when String
        helpers.sanitize(val)
      else
        # Nothing to do, use val as is
        val
      end
    end
943239
private String
sanitize(String str) {
	if (wordcase == CASE_UPPER)
		return str.toUpperCase();
	else if (wordcase == CASE_LOWER)
		return str.toLowerCase();
	return str;
}
1081947
public Transliterator safeClone() {
        UnicodeFilter filter = getFilter();
        if (filter != null && filter instanceof UnicodeSet) {
            filter = new UnicodeSet((UnicodeSet)filter);
        }
        return new AnyTransliterator(getID(), filter, target, targetScript, widthFix, cache);
    }
595777
def _sanitize_to_unicode(obj):
        
        if isinstance(obj, dict):
            return dict((BaseGELFHandler._sanitize_to_unicode(k), BaseGELFHandler._sanitize_to_unicode(v)) for k, v in obj.items())
        if isinstance(obj, (list, tuple)):
            return obj.__class__([BaseGELFHandler._sanitize_to_unicode(i) for i in obj])
        if isinstance(obj, data):
            obj = obj.decode('utf-8', errors='replace')
        return obj
980647
function translateInLanguageFilter(key, locale) {
    for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
      args[_key - 2] = arguments[_key];
    }

    return translateInLanguage.apply(void 0, [locale, key].concat(args));
  }