Problem with hidden 'character' in a string, how do I remove?

Welcome Forums General PowerShell Q&A Problem with hidden 'character' in a string, how do I remove?

Viewing 7 reply threads
  • Author
    Posts
    • #189280
      Participant
      Topics: 1
      Replies: 3
      Points: 23
      Rank: Member

      Hi everyone,

      I'm trying to work out why a string cannot be trimmed and it seems there's some sort of hidden character at the start.

      It simply shows as a blank space in Visual Code, but appears as a strange 'symbol' in PowerShell 7 preview, if I export the variable value to a txt file it doesn't appear in notepad (however if I hold shift and right-key the cursor highlight the apparent first character on the first press and starts blinking between black and red – suggesting that a hidden character is present or something).

      It's hard to explain so I've attached a link to a screenshot that hopefully shows the logical steps I've taken to identify this.

      PowerShell string containing unknown 'character'

      Does anybody have any ideas how I can remove this 'thing' ?

      Thanks

    • #189298
      Participant
      Topics: 1
      Replies: 3
      Points: 23
      Rank: Member

      I've resolved my problem using:-

      $br = $br -replace $br[0],"

      I've still no idea what the character is however (it looks like a rectangle standing on it's shorter side).

    • #189319
      Participant
      Topics: 1
      Replies: 1632
      Points: 3,074
      Helping Hand
      Rank: Community Hero

      Just a little hint for the next time you want to post code: An image of your code is not helpful.

    • #189325
      Participant
      Topics: 1
      Replies: 3
      Points: 23
      Rank: Member

      Hi,

      The image was included as there's no other way for me to describe the character that's showing up. I can't even type the character on the keyboard to include in plain text.

      If I knew how to include code that shows a hidden character I'd have shown the code.

      Thanks.

    • #189328
      js
      Participant
      Topics: 27
      Replies: 716
      Points: 1,879
      Helping Hand
      Rank: Community Hero

      What is the string from? I've heard of that before, maybe an alignment character adobe uses or something in the title of a file.

    • #189331
      Participant
      Topics: 1
      Replies: 3
      Points: 23
      Rank: Member

      What is the string from? I've heard of that before, maybe an alignment character adobe uses or something in the title of a file.

      Hi,

      I found a script online that extracts the meta data from an .mp3 file using Shell.Namespace.

      The string in my example is value of the bit rate output from the mp3.

      I wanted to simply extract the digits from the string so I could create an integer variable for bitrate instead but kept getting a conversion error and that's when I noticed that the variable length was longer than the characters shown.

      I eventually solved that by using -replace "[^0-9]",", but that doesn't help me understand how or what the hidden character was in the first place.

      I'm guessing there's something specific/unique about the mp3 tag for bitrate that results in this strange occurrence in this instance.

      Thanks.

    • #189334
      Participant
      Topics: 1
      Replies: 1632
      Points: 3,074
      Helping Hand
      Rank: Community Hero

      Maybe some more explanation: If you post a question in a forum about some code it would be helpful for the people willing to help to actually see (or have) the code to be able to reproduce the behaviour or the error or whatever issue you have with this particular code. If you're not able to share the actual code you shold share some example code to enable the helpers to reproduce your issue. 😉

      So if you have this code from a website you should either post the code or at least a link to the website.

    • #189487
      Participant
      Topics: 0
      Replies: 5
      Points: 7
      Rank: Member

      I wonder if this might help you figure it out

      https://en.wikipedia.org/wiki/ID3

      For the curious in all of us, please post what you find. Thanks.

Viewing 7 reply threads
  • You must be logged in to reply to this topic.