Control characters ignored

Posted 63 days ago by euroeager2008
Edited 63 days ago

An input element in a razor page is not able to expose control characters (particularly 0x1d (Group Separator))
Some possible workaround?

EDIT: I forgot to mention that the input is a USB barcode scanner, transmitting info similar to a USB keyboard

Blazor server or WASM, WASM preferred.

  • 0


    just a thought maybe there is a way via localization.

    Posted 61 days ago by nogood
  • 0


    Wish I really understood (isn't localization only for interpreting formats like dates and ditto presentation?).
    I have tried a bit with charset="utf-8" attribute to no avail.
    Would you kindly be somewhat more specific? (perhaps a small code snippet)

    Posted 61 days ago by euroeager2008
  • 0

    It may help if you provide code to show the issue.

    Posted 59 days ago by selliott
  • 0

    Ok, I will try as follows:

    First some notes:
    It is a bit difficult to highlight my issue due to currently lacking the actual barcode scanner, however the scanner, if scanning into Notepad++ ( would result in something like:
    240ArticlenumberSurrogate92RevsionSurrogate21SerialNumberSurrogate (Difficult to show here, but the squares are represented as the letters GS with black background in notepad++)
    Saving the notepad++ file and using e.g. Hex Editor Neo ( shows that both the GS's indeed are 0x1D (ascii).
    I get the same result (regarding GS) if I press ctrl-^ on my (Norwegian) keyboard so, in lack of the actual scanner and for testing, I assume this can be used to simulate the scanners GS's

    The following code snip is (by me) expected to show (in Chrome console) something like ABC<0x001D>DEF if I enter ABC followed by ctril-^ followed by DEF, in th input field (Blazor wasm in this case), but the GS is simply filtered away by Chrome (and other browsers) seemingly.
    This is of course not my real code, but for the sake of describing the issue).

    @page "/"
    @using ScannerEntry.Shared
    @using System.Text
    <input size="100" @bind="RawscanValue" />
    @code {
        private string rawscanValue;
        private string RawscanValue
            get { return rawscanValue; }
                rawscanValue = value;
                    StringBuilder sb = new StringBuilder();
                    char[] characters = rawscanValue.ToCharArray();
                    foreach (char character in characters)
                        if (char.IsControl(character))
                            byte[] bytes = BitConverter.GetBytes(character);
                            sb.Append(BitConverter.ToInt16(bytes, 0).ToString("X4"));
                        else sb.Append(character);
                    // Control character byte value will be enclosed within <> and given as hexadecimal valye (e.g. <0x001D>)
                    Console.WriteLine($"Entered value (space delimited characters): {sb.ToString()}");
                catch (Exception exception)
                    Console.WriteLine($"{exception.GetType().Name} occurred, message:\n{exception.Message}");

    Indirectly I have tried this with the actual scanner (a bit different code though) and the GS indeed simply disappears.

    As a sidenote, if I add some code to write a modified value (containing GS's) into the bound property, it is shown as squares, exactly like described above when copied from Notepad++

    Posted 59 days ago by euroeager2008
Someone is typing...

Post a Reply

You must be logged in to add a new post.
Number of online users: 0
An error has occurred. This application may no longer respond until reloaded. Reload 🗙