summaryrefslogtreecommitdiff
path: root/java/com/android/vcard/VCardUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/vcard/VCardUtils.java')
-rw-r--r--java/com/android/vcard/VCardUtils.java31
1 files changed, 26 insertions, 5 deletions
diff --git a/java/com/android/vcard/VCardUtils.java b/java/com/android/vcard/VCardUtils.java
index a486d5d..5890fb4 100644
--- a/java/com/android/vcard/VCardUtils.java
+++ b/java/com/android/vcard/VCardUtils.java
@@ -15,18 +15,15 @@
*/
package com.android.vcard;
-import com.android.vcard.exception.VCardException;
-
-import android.content.ContentProviderOperation;
-import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.CommonDataKinds.Im;
import android.provider.ContactsContract.CommonDataKinds.Phone;
-import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
import android.telephony.PhoneNumberUtils;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.util.Log;
+import com.android.vcard.exception.VCardException;
+
import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
@@ -697,6 +694,30 @@ public class VCardUtils {
return true;
}
+ /**
+ * Checks to see if a string looks like it could be an android generated quoted printable.
+ *
+ * Identification of quoted printable is not 100% reliable since it's just ascii. But given
+ * the high number and exact location of generated = signs, there is a high likely-hood that
+ * it would be.
+ *
+ * @return True if it appears like android quoted printable. False otherwise.
+ */
+ public static boolean appearsLikeAndroidVCardQuotedPrintable(String value) {
+
+ // Quoted printable is always in multiple of 3s. With optional 1 '=' at end.
+ final int remainder = (value.length() % 3);
+ if (value.length() < 2 || (remainder != 1 && remainder != 0)) {
+ return false;
+ }
+ for (int i = 0; i < value.length(); i += 3) {
+ if (value.charAt(i) != '=') {
+ return false;
+ }
+ }
+ return true;
+ }
+
//// The methods bellow may be used by unit test.
/**