package co.smartreceipts.android.workers.reports.pdf.utils;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
/**
* If PDFBox does not support a particular character, we straight-up crash. As a short-term fix,
* we're just going to replace these illegal characters with "?" ones. As we grow, we should look
* into much more graceful solutions (eg rendering these on Android and then converting the text
* Canvas into an image of the glyph).
*/
public class HeavyHandedReplaceIllegalCharacters {
@NonNull
public static String getSafeString(@Nullable String string) {
if (string != null) {
return string.replaceAll("\\p{C}", "");
} else {
return "";
}
}
}