Reputation: 912
I am pulling text from an embedded .txt file and then displaying it in a label. iOS is fine, but Android shows extra characters. I am missing something simple but not sure what. Thanks for the help.
This (in a .txt file):
0.2.3
- Fixed spelling errors
- Added version number in slide-out menu
- Squashed bugs
0.2.2
- Database Change Log Added.
- Bug Fixes.
0.2.1
- Bug Fixes
Turns into this:
The space characters are bring shown. How do I prevent this?
Retrieving the text:
var assembly = typeof(MainMenuViewModel).GetTypeInfo().Assembly;
Stream stream = assembly.GetManifestResourceStream("ReleaseNotes.txt");
var text = "";
using (var reader = new StreamReader(stream))
{
text = reader.ReadToEnd();
}
ReleseNotesText = text;
The Label:
<Label Text="{Binding ReleseNotesText}" HorizontalTextAlignment="Start" HorizontalOptions="Fill" VerticalOptions="CenterAndExpand" TextColor="{DynamicResource TextColor}" FontSize="18" />
Upvotes: 1
Views: 295
Reputation: 28272
More likely your newlines are \n
in the embedded text file stream
Just convert them to the correct environment newline. Newline character(s) may vary depending on the running platform... in .NET you have the handy Environment.NewLine
, thus:
ReleseNotesText = text.Replace("\n", Environment.NewLine);
Edit: after taking a look at the exact text file in the comments, it looks like it was using the U+2028 unicode sequence for newlines. The correct replacing code would be:
ReleseNotesText = text.Replace("\u2028", Environment.NewLine);
Upvotes: 1