2017-09-02 14:49



I have an Android app that retrieves values from a servers database and displays them in the app but carriage returns are coming back as but I need them to act as carriage that will place text below onto a new line.

I first post data to my server to store in database like this:

$body = mysqli_real_escape_string($conn, $_POST['body']); 

Then I encrypt the text before storing in database like this

$encryptedBodyText = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $body, MCRYPT_MODE_CBC, md5(md5($key))));

I now get the data from the database and then JSON it to android

$decryptedBody = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($body), MCRYPT_MODE_CBC, md5(md5($key))), "\0");

but when I show this data in the android the new lines are shown as instead of actual new lines.

How can I replace the so they are actual new lines in java

I've tried

String t = sharedBodyText.replace("

and it doesn't work but if I change to

String t = sharedBodyText.replace("gg",System.getProperty("line.separator"));

it does work if there is "gg" in the body text

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dpjpo746884 dpjpo746884 4年前

    How about replacing with System.getProperty("line.separator") in Android side

    Try this:

    ", System.getProperty("line.separator"));
    点赞 评论 复制链接分享