Code Duplication    Length = 41-41 lines in 2 locations

3rdparty/getID3/getid3/getid3.lib.php 2 locations

@@ 1051-1091 (lines=41) @@
1048
	 *
1049
	 * @return string
1050
	 */
1051
	public static function iconv_fallback_utf8_utf16be($string, $bom=false) {
1052
		$newcharstring = '';
1053
		if ($bom) {
1054
			$newcharstring .= "\xFE\xFF";
1055
		}
1056
		$offset = 0;
1057
		$stringlength = strlen($string);
1058
		while ($offset < $stringlength) {
1059
			if ((ord($string{$offset}) | 0x07) == 0xF7) {
1060
				// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
1061
				$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
1062
						   ((ord($string{($offset + 1)}) & 0x3F) << 12) &
1063
						   ((ord($string{($offset + 2)}) & 0x3F) <<  6) &
1064
							(ord($string{($offset + 3)}) & 0x3F);
1065
				$offset += 4;
1066
			} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
1067
				// 1110bbbb 10bbbbbb 10bbbbbb
1068
				$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
1069
						   ((ord($string{($offset + 1)}) & 0x3F) <<  6) &
1070
							(ord($string{($offset + 2)}) & 0x3F);
1071
				$offset += 3;
1072
			} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
1073
				// 110bbbbb 10bbbbbb
1074
				$charval = ((ord($string{($offset + 0)}) & 0x1F) <<  6) &
1075
							(ord($string{($offset + 1)}) & 0x3F);
1076
				$offset += 2;
1077
			} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
1078
				// 0bbbbbbb
1079
				$charval = ord($string{$offset});
1080
				$offset += 1;
1081
			} else {
1082
				// error? throw some kind of warning here?
1083
				$charval = false;
1084
				$offset += 1;
1085
			}
1086
			if ($charval !== false) {
1087
				$newcharstring .= (($charval < 65536) ? self::BigEndian2String($charval, 2) : "\x00".'?');
1088
			}
1089
		}
1090
		return $newcharstring;
1091
	}
1092
1093
	/**
1094
	 * UTF-8 => UTF-16LE
@@ 1101-1141 (lines=41) @@
1098
	 *
1099
	 * @return string
1100
	 */
1101
	public static function iconv_fallback_utf8_utf16le($string, $bom=false) {
1102
		$newcharstring = '';
1103
		if ($bom) {
1104
			$newcharstring .= "\xFF\xFE";
1105
		}
1106
		$offset = 0;
1107
		$stringlength = strlen($string);
1108
		while ($offset < $stringlength) {
1109
			if ((ord($string{$offset}) | 0x07) == 0xF7) {
1110
				// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
1111
				$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
1112
						   ((ord($string{($offset + 1)}) & 0x3F) << 12) &
1113
						   ((ord($string{($offset + 2)}) & 0x3F) <<  6) &
1114
							(ord($string{($offset + 3)}) & 0x3F);
1115
				$offset += 4;
1116
			} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
1117
				// 1110bbbb 10bbbbbb 10bbbbbb
1118
				$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
1119
						   ((ord($string{($offset + 1)}) & 0x3F) <<  6) &
1120
							(ord($string{($offset + 2)}) & 0x3F);
1121
				$offset += 3;
1122
			} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
1123
				// 110bbbbb 10bbbbbb
1124
				$charval = ((ord($string{($offset + 0)}) & 0x1F) <<  6) &
1125
							(ord($string{($offset + 1)}) & 0x3F);
1126
				$offset += 2;
1127
			} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
1128
				// 0bbbbbbb
1129
				$charval = ord($string{$offset});
1130
				$offset += 1;
1131
			} else {
1132
				// error? maybe throw some warning here?
1133
				$charval = false;
1134
				$offset += 1;
1135
			}
1136
			if ($charval !== false) {
1137
				$newcharstring .= (($charval < 65536) ? self::LittleEndian2String($charval, 2) : '?'."\x00");
1138
			}
1139
		}
1140
		return $newcharstring;
1141
	}
1142
1143
	/**
1144
	 * UTF-8 => UTF-16LE (BOM)