This is the function I am using to generate a QR file:
import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
public boolean generateQRCode(String qrCodeContent, String filePath, int width, int height) {
try {
QRCodeWriter qrCodeWriter = new QRCodeWriter();
BitMatrix bitMatrix = qrCodeWriter.encode(qrCodeContent, BarcodeFormat.QR_CODE, width, height);
Path path = Paths.get(filePath);
MatrixToImageWriter.writeToPath(bitMatrix, "PNG", path);
return true;
} catch (WriterException | IOException e) {
log.error("Exception occurred while generating QR Code", e);
}
return false;
}
When I am sending the ₹
symbol in qrCodeContent
string, nothing goes wrong, the QR code gets generated successfully.
However, when I scan the code, all those places where ₹
was there are replaced by ?
.
The variable qrCodeContent
is of type String
which contains a normal string with literals like Your total saving are ₹ 100.00
.