private String getTag(byte[] data, String name) {

		try {
		
			// get the start position of the tag we searched for
			int pos = ByteHelper.indexOf(data, name);
						
			// tag not set? => return empty string
			if (pos == -1) {return "";}

			int charset, pos2, pos3, size;

			// ID3v2.2
			if (name.length() == 3) {
				
				pos2 = pos + 3;
				pos3 = pos + 7;
				size = getInt3(data, pos2);
				charset = data[pos3-1];
				
			// ID3V2.3 and ID3v2.4
			} else {
				
				pos2 = pos + 4;
				pos3 = pos + 11;
				size = getInt4(data, pos2);
				charset = data[pos3-1];
				if (name == V3_IMAGE) {charset = 9;}
				
			}

			// convert string using the correct charset
			switch (charset) {
				
				case 0:	return new String(data, pos3, size-1, "ISO-8859-1").trim();
				
				case 1: return new String(data, pos3, size-1, "UTF-16").trim();
				
				case 2: return new String(data, pos3, size-1, "UTF-16BE").trim();
				
				case 3: return new String(data, pos3, size-1, "UTF-8").trim();
				
				case 9:
					int headerSize = 10;
					cover = new ID3Image(file, pos3+headerSize, size-1);
					//byte[] outImg = new byte[size-1];
					//System.arraycopy(data, pos3, outImg, 0, size-1);
					//bImg = getPicture(outImg);
					return null;
				
				default: return "";
			
			}


		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
	}