Used to invert an escape array into an unescape array
@param array String[][] to be inverted
@return String[][] inverted array
515078
public static String[][] invert(final String[][] array) {
        final String[][] newarray = new String[array.length][2];
        for(int i = 0; i<array.length; i++) {
            newarray[i][0] = array[i][1];
            newarray[i][1] = array[i][0];
        }
        return newarray;
    }
364575
protected static function encodeArray($array)
    {
        if (Arrays::isAssoc($array)) {
            $output = [];
            foreach ($array as $key => $val) {
                $output[] = $key . ':' . \addcslashes($val, ': ');
            }

            return self::encodeString(\implode(' ', $output));
        }

        $output = [];
        foreach ($array as $val) {
            $output[] = \addcslashes($val, ': ');
        }

        return self::encodeString(\implode(' ', $output));
    }
1332743
public static function caseConvertArrayKeysRecursively(
        array $array,
        string $method = self::PASCALCASE,
        string $separator = '_'
    ): array {
        $return = [];
        foreach ($array as $key => $value) {
            if (!preg_match('/^\d+$/', $key)) {
                $key = self::$method(preg_replace('/\-/', '_', $key), true, $separator);
            }
            if (is_array($value)) {
                $value = self::caseConvertArrayKeysRecursively($value, $method);
            }
            $return[$key] = $value;
        }
        return $return;
    }
293126
public static function keyFlattening($array, $keys = []) {
		if (is_array($array)) {
			$result = [];
			foreach ($array as $key => $value) {
				$tmp_keys = $keys;
				$tmp_keys [] = $key;
				$result = array_merge($result, static::keyFlattening($value,$tmp_keys));
			}
			return $result;
		}

		$key = array_shift($keys);
		return [
			empty($keys) ? $key : sprintf('%s[%s]', $key, implode ('][', $keys)) => $array,
		];
	}
966523
public static function keyToCamel($array)
    {
        $result = [];
        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $result[Strings::case2camel($key)] = self::keyToCamel($value);
            } else {
                $result[Strings::case2camel($key)] = $value;
            }
        }
        return $result;
    }
1110933
def decode_array(values):
    
    out = []
    for val in values:
        try:
            out.append(val.decode('utf8'))
        except AttributeError:
            out.append(val)
    return out
900510
final public function escapeValues (array $values) : array
	{
		$sanitizedValues = [];
		foreach ($values as $key => $value):
			$key 					= $this->escapeValue($key);
			$sanitizedValues[$key]  = (is_array($value)) ? $this->escapeValues($value) : $this->escapeValue($value);
		endforeach;
		return $sanitizedValues;
	}
235176
function unescapeUnicode(str) {
    	    // unescape unicode codes
    	    var codes = [];
    	    var code = parseInt(str.substr(2), 16);
    	    if (code >= 0 && code < Math.pow(2, 16)) {
    		codes.push(code);
    	    }
    	    // convert codes to text
    	    var unescaped = '';
    	    for (var i = 0; i < codes.length; ++i) {
    		unescaped += String.fromCharCode(codes[i]);
    	    }
    	    return unescaped;
    	}
332267
private function unescapeLatinCharacters($str)
    {
        if ($this->latinCharacters) {
            $str = vsprintf($str, $this->latinCharacters);
            $this->latinCharacters = array();
        }

        return $str;
    }
862254
protected function _decodeArray()
    {
        $result = array();
        $tok = $this->_getNextToken(); // Move past the '['
        $index  = 0;

        while ($tok && $tok != self::RBRACKET) {
            $result[$index++] = $this->_decodeValue();

            $tok = $this->token;

            if ($tok == self::RBRACKET || !$tok) {
                break;
            }

            if ($tok != self::COMMA) {
                throw new RuntimeException('Missing "," in array encoding: ' . $this->source);
            }

            $tok = $this->_getNextToken();
        }

        $this->_getNextToken();
        return $result;
    }
643916
public static function quoteStrings(array $array)
    {
        /*
         * No elements?
         * Nothing to do
         */
        if (empty($array)) {
            return null;
        }

        $result = [];

        foreach ($array as $index => $value) {
            if (is_array($value)) {
                $value = self::quoteStrings($value);
            } elseif (is_string($value)) {
                if (!Regex::isQuoted($value)) {
                    $value = '\'' . $value . '\'';
                }
            }

            $result[$index] = $value;
        }

        return $result;
    }
756660
public function serializeStrings(array $strings)
	{
		$info         = $this->analyzeStrings($strings);
		$alternations = array_map([$this, 'serializeString'], $info['strings']);
		if (!empty($info['chars']))
		{
			// Prepend the character class to the list of alternations
			array_unshift($alternations, $this->serializeCharacterClass($info['chars']));
		}

		$expr = implode('|', $alternations);
		if ($this->needsParentheses($info))
		{
			$expr = '(?:' . $expr . ')';
		}

		return $expr . $info['quantifier'];
	}
1146576
static void unescape(final char[] text, final int offset, final int len, final Writer writer)
            throws IOException {

        if (text == null) {
            return;
        }

        final int max = (offset + len);

        int readOffset = offset;
        int referenceOffset = offset;

        for (int i = offset; i < max; i++) {

            final char c = text[i];

            /*
             * Check the need for an unescape operation at this point
             */

            if (c != ESCAPE_PREFIX || (i + 1) >= max) {
                continue;
            }

            int codepoint = -1;

            if (c == ESCAPE_PREFIX) {

                final char c1 = text[i + 1];

                switch (c1) {
                    case 't': codepoint = 0x09; referenceOffset = i + 1; break;
                    case 'n': codepoint = 0x0A; referenceOffset = i + 1; break;
                    case 'f': codepoint = 0x0C; referenceOffset = i + 1; break;
                    case 'r': codepoint = 0x0D; referenceOffset = i + 1; break;
                    case '\\': codepoint = 0x5C; referenceOffset = i + 1; break;
                }

                if (codepoint == -1) {

                    if (c1 == ESCAPE_UHEXA_PREFIX2) {
                        // This can be a uhexa escape, we need exactly four more characters

                        int f = i + 2;
                        while (f < (i + 6) && f < max) {
                            final char cf = text[f];
                            if (!((cf >= '0' && cf <= '9') || (cf >= 'A' && cf <= 'F') || (cf >= 'a' && cf <= 'f'))) {
                                break;
                            }
                            f++;
                        }

                        if ((f - (i + 2)) < 4) {
                            // We weren't able to consume the required four hexa chars, leave it as slash+'u', which
                            // is invalid, and let the corresponding Java Properties parser fail.
                            i++;
                            continue;
                        }

                        codepoint = parseIntFromReference(text, i + 2, f, 16);

                        // Fast-forward to the first char after the parsed codepoint
                        referenceOffset = f - 1;

                        // Don't continue here, just let the unescape code below do its job


                    } else {

                        // We weren't able to consume any valid escape chars, just consider it a normal char,
                        // which is allowed by the Java Properties specification

                        codepoint = (int) c1;
                        referenceOffset = i + 1;

                    }

                }

            }


            /*
             * At this point we know for sure we will need some kind of unescape, so we
             * write all the contents pending up to this point.
             */

            if (i - readOffset > 0) {
                writer.write(text, readOffset, (i - readOffset));
            }

            i = referenceOffset;
            readOffset = i + 1;

            /*
             * --------------------------
             *
             * Perform the real unescape
             *
             * --------------------------
             */

            if (codepoint > '\uFFFF') {
                writer.write(Character.toChars(codepoint));
            } else {
                writer.write((char)codepoint);
            }

        }


        /*
         * -----------------------------------------------------------------------------------------------
         * Final cleaning: writer the remaining escaped text and return.
         * -----------------------------------------------------------------------------------------------
         */

        if (max - readOffset > 0) {
            writer.write(text, readOffset, (max - readOffset));
        }

    }
881184
private static String unescape(String string) {
    return StringUtils.unEscapeString(string, StringUtils.ESCAPE_CHAR, 
                                      charsToEscape);
  }
1296462
public static String unescape(String string, char escape)
   {
      CharArrayWriter out = new CharArrayWriter(string.length());
      for (int i = 0; i < string.length(); i++)
      {
         char c = string.charAt(i);
         if (c == escape)
         {
            try
            {
               out.write(Integer.parseInt(string.substring(i + 1, i + 3), 16));
            }
            catch (NumberFormatException e)
            {
               throw new IllegalArgumentException(e);
            }
            i += 2;
         }
         else
         {
            out.write(c);
         }
      }
      return new String(out.toCharArray());
   }
417542
private static function _getCharMap(): array
    {
        // Keep local copy
        static $map = [];

        if (empty($map)) {
            // This will replace accented chars with non-accented chars
            foreach (StringHelper::asciiCharMap() as $asciiChar => $charsArray) {
                foreach ($charsArray as $char) {
                    $map[$char] = $asciiChar;
                }
            }

            // Replace punctuation with a space
            foreach (self::_getPunctuation() as $value) {
                $map[$value] = ' ';
            }
        }

        // Return the char map
        return $map;
    }
93919
private function encoding( $array, $to_encoding = 'UTF-8', $from_encoding = 'GBK' ) : array
	{
		$encoded = [];
		foreach( $array as $key => $value ){
			if( is_array( $value ) ){
				$encoded[$key] = $this->encoding( $value, $to_encoding, $from_encoding );
			} elseif( is_bool( $value ) ){
				$encoded[$key] = $value;
			} elseif( is_string( $value ) && mb_detect_encoding( $value, 'UTF-8', true ) ){
				$encoded[$key] = $value;
			} else{
				$encoded[$key] = mb_convert_encoding( $value, $to_encoding, $from_encoding );
			}
		}
		return $encoded;
	}