Skip to content

Instantly share code, notes, and snippets.

@wuyongzheng
Created June 15, 2011 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wuyongzheng/1026751 to your computer and use it in GitHub Desktop.
Save wuyongzheng/1026751 to your computer and use it in GitHub Desktop.
Decode xiami xml's location url
public static String dexiami (String code)
{
int i2 = Integer.parseInt(code.substring(0, 1));
code = code.substring(1);
int i4 = code.length() / i2;
int i5 = code.length() % i2;
String [] arr = new String [i2];
for (int count = 0; count < i5; count ++)
arr[count] = code.substring((i4 + 1) * count, (i4 + 1) * (count + 1));
for (int count = i5; count < i2; count ++)
arr[count] = code.substring(i4 * count + i5, i4 * (count + 1) + i5);
String txt = "";
for (int count = 0; count < i4 + 1; count ++) {
for (int j = 0; j < i2; j ++) {
if (count < arr[j].length())
txt += arr[j].charAt(count);
}
}
txt = java.net.URLDecoder.decode(txt, "UTF-8");
txt = txt.replace('^', '0');
txt = txt.replace('+', ' '); // not sure if this is needed
return txt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment