Stavros
Stavros

Reputation: 147

text from barcode scanner being filtered out when entered into UWP textbox

I am developing an app which reads the info from a barcode scanner then parses the information.

when I scan the information into a text box the '\n' line feed character is being filtered out from the textbox. I have made accept returns = true but in still getting the same issue.

when I scan the information into notepad I am getting the \n line feed character so I know it is present. I also get \r\n which are different from the line feeds which my application is able to read.

my question is, how can I make the text box accept line feeds

Upvotes: 0

Views: 328

Answers (1)

Stefan Over
Stefan Over

Reputation: 6046

You cannot. The Windows TextBox only accepts \r\n as line breaks. \n will be ignored.

To represent a new line for each \n character, you'll have to replace it with the Windows representation of a new line.

var input = GetInputFromScanner();
var cleanInput = input.Replace("\n", Environment.NewLine);
// Assign "cleanInput" to your "TextBox" instance

Upvotes: 1

Related Questions