Reputation: 1606
I have a multi-lang app which retrieves the translations from strings.xml.
It was working correctly but after migration (maybe regarding VS 2019), \r\n becomes r\n and always I see an extra "r" char in my translated text because of missing backslash.
For example
<string name="general_checkforupdate_updateavailableOnGooglePlay_Message">
New version (v{0}) is available on Google Play.\r\nWould you like to update it now?</string>
and the code
string message= string.Format(_activity.GetString(
Resource.String.general_checkforupdate_updateavailableOnGooglePlay_Message),
newVersionInfo.Version);
I see the message like this
and when I read this part in debug
_activity.GetString(Resource.String.general_checkforupdate_updateavailableOnGooglePlay_Message)
I see the message is New version (v{0}) is available on Google Play.r\nWould you like to update it now?
As you see \ backslash character is deleted but for \n is OK. what can be the reason?
Upvotes: 1
Views: 563
Reputation: 15001
In Android, users tend to put all of the string stored in the string. The XML, the purpose is convenient and unified management, and conducive to the internationalization, but direct input symbols in the string is no effect, such as Spaces, line breaks, is greater than, less than, etc., which requires the use of escape characters to transfer, such ability when use correctly display character.
you could refer to below :
Space: 
(normal English half space but not line break)
Narrow Space: 
 
(full corner space (one Chinese width))
 
(half Chinese width, but two Spaces are slightly larger than one Chinese)
 
(one Chinese width, but slightly wider than Chinese)
\u3000\u3000
(first line indent)
\u3000
(full corner space (Chinese symbol))
\u0020
(half corner space (English symbol))
…
(ellipsis)
so you could try to use  
or \u3000
Upvotes: 1
Reputation: 723
The \r
does not work on all platforms / terminals in the same way. See Difference between \n and \r?. On your system it is replaced by r
, because it might not support it.
Upvotes: 1