473,387 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to catch (or prevent) "Found a low surrogate char..." error

I need to convert an incoming byte array to a Unicode string, when (if) that
byte array contains valid Unicode values (sometimes it doesn't).

I've been trying to use UnicodeEncoding.GetString(bytes)...

However, when the byte array doesn't contain value Unicode values, I get a
"Found a low surrogate char without a preceding high surrogate at index..."
exception.

I understand why the error occurs, but I don't understand how to catch (and
ignore) the exception. For example, fhe following doesn't work...

Try
Dim c As String = enc.GetString(bytes)
Catch ex As Exception
...
End Try

.... the Catch is never entered.

So, how do I...

1) catch the exception

OR (preferably)

2) do a "test" on the byte array to ensure it contains valid Unicode values
BEFORE I actually do the conversion (which to me would seem to be more
efficient than causing/catching/ignoring an exception).

BTW: this is .NET 1.1

????

Mar 28 '07 #1
0 1281

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: viditm | last post by:
Hi I keep getting the error "Error Creating Windows Handle" in my application and different places in the code. This occurs only to certain users. Its very random and cannot be reproduced in the...
1
by: Krusty276 | last post by:
I'm getting this error using sql plus Input is too long (> 2499 characters) - line ignored This is my command line on linux: /home/oracle/product/8.1.6/bin/sqlplus -s loader/loader@ecrmdb...
7
by: Baloff | last post by:
Hello I have this line in my c++ code and it is giving the error below, not sure why, I tried it on different boxes, same error. thanks the last line in my main() I have this system(...
1
by: Phillip | last post by:
I just ran into this problem also. (undocumented exception thrown when Streamwriter is handed a buffer with wierd characters in it). I was also able to get around it by specifying utf8 as the...
3
by: Stephen Miller | last post by:
I have an ASP.Net application that sends a NetworkStream to a .Net Service, which has a TcpListener listening on a port for the ASP.Net client. When it receives a request it creates a new thread...
4
by: rukkie | last post by:
Hi, I have some problems with a PHP reference in a <SCRIPTtag, but only with the Internet Explorer, which gives a "Error on page" message in the Status Bar. The code is as follows : <script>...
1
by: Alexander Higgins | last post by:
>>Thanks for the response.... Point Taken but this is not the case. Thus, if a person writes a text file on her or his computer and does not use UNICODE to save it, the current code page is...
4
by: makweatan | last post by:
Hello, Can anyone please help me, where did I go wrong..? Line : 388 Char : 1 Error : Object Expected Code : 0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
9
whatelyb
by: whatelyb | last post by:
I am having trouble related to the attached coding. I am trying to make the object "flight1pic" change depending on what is selected in the drop down menus "airline1" and "aircraft1". My...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.