We help IT Professionals succeed at work.

Byte array to string, encoding problems with + plus symbol

jasww asked
Last Modified: 2008-05-29
I have a byte array that when decoded shoudl contain plus symbols and accented characters.
Part of the string is "5190056340+51900112190" and also  "Nürnberg  +49/9221/709-286"

The plus symbols are being mis-interpreted when I decode from a pure binary stream in the byte array to UTF7.  

When I pull it out using ASCII (and save to notepad), I see "N|rnberg +49/9221/709-286", which is the right phone number but note how the Umlaut in Neurenburg has gone.   The other part comes out as 5190056340????.

When I decode with UTF7 (and save to notepad) I see this: "Nürnberg ß?O286". The umlaut is there, but some how the plus symbol has turn the following 12 characters into nonsense. This is the encoding I use in the program.

When I use UTF8 (and save to notepad), I see this:
"Nrnberg +49/9221/709-286"
The letter U has disappeared!

I am able to use Windows-1252 encoding, which preserves the umluat and also correctly understands the plus sign.

My question is:  when does the + sign force the numbers that follow it to come out as nonsense, and how can I prevent it when not using Windows-1252?

Watch Question

Most Valuable Expert 2012
Top Expert 2008

There a different encoders, so did you try them all to see the results (Default, Unicode, UTF7, UTF8, ...)?



Yes, I did, and none is quite right.  The default is 1252.  I've got it working with 1252, I just wanted to know why the data was beuing misinterpreted when using the other encodings.  It's as if the bytes are converted to the string "+49" (the phone number), and then a second conversion occurs (as if the engine has said to itself, "hello, this is a special string, I must further decode it") to turn this into nonsense.
Most Valuable Expert 2012
Top Expert 2008
Unlock this solution and get a sample of our free trial.
(No credit card required)


Well someone might as well have the points then......

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.