Ibanez1408
Ibanez1408

Reputation: 5058

Line breaks is not being followed on printing in Kotlin

I am getting this format from a json string:

ABCD\n EFG: HIJKL\n 
MNO: PQRST \n\n
UVW: XYZ

When I print it, the line breaks ("\n") is not inserted. I get the Json string like so:

val orReply = gson.fromJson<OrReply>(decryptedValue, OrReply::class.java)
printReceipt(orReply.ORData)

and use this reply as so:

private fun printReceipt(orString: String) {
   printOnPrinter(orString)
}

Upvotes: 0

Views: 73

Answers (1)

Sahil Manchanda
Sahil Manchanda

Reputation: 10012

Try the following function to process the line breaks and see if helps you in fixing the issue:

private fun processLineBreak(string: String) : String{
        return string.replace("\n",System.lineSeparator())
}

Upvotes: 1

Related Questions