summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwjoe <joe@lc8n.com>2013-09-24 14:08:56 +0100
committerwjoe <joe@lc8n.com>2013-09-24 14:08:56 +0100
commit9b2b57aab41337005912a0003e5c8700556bc607 (patch)
treefc758bf2ab43591f0ecdf607a4ed3019e6726932
parentc1c37366d436dfd9896884ac02431074c5b3bb72 (diff)
Replace \u encoded characters with the correct characters
-rwxr-xr-x[-rw-r--r--]blasearch.java22
1 files changed, 18 insertions, 4 deletions
diff --git a/blasearch.java b/blasearch.java
index a5af42c..6ca2295 100644..100755
--- a/blasearch.java
+++ b/blasearch.java
@@ -32,6 +32,8 @@ public class blasearch {
{
String query = "";
+ String version = "v1.2.1";
+
/* Build query from query or arguments, depending on whether
arguments were given. */
if (args.length == 0) {
@@ -48,7 +50,10 @@ public class blasearch {
query += args[i];
}
}
-
+ if (query.equals("-v") || query.equals("--version")) {
+ System.out.println(version);
+ System.exit(0);
+ }
// Change all ' ' to '+'
query = query.replaceAll(" ", "+");
@@ -73,11 +78,20 @@ public class blasearch {
for(int i=0; i<lines.length; i++){
// Get the useful information (the urls!)
- if(lines[i].startsWith("\"url\"")){
+ if(lines[i].startsWith("\"unescapedUrl\"")){
tempString = lines[i];
// Blat the non-url information
- tempString = tempString.substring(7, tempString.length()-1);
- results.add(tempString);
+ tempString = tempString.substring(16, tempString.length()-1);
+ String[] searchParts = tempString.split("\\\\u");
+ String searchResult = searchParts[0];
+ if (searchParts.length > 1) {
+ for (int j = 1; j < searchParts.length; j++) {
+ int hexVal = Integer.parseInt(searchParts[j].substring(0,4),16);
+ searchResult += (char)hexVal;
+ searchResult += searchParts[j].substring(4);
+ }
+ }
+ results.add(searchResult);
}
}