473,398 Members | 2,525 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,398 software developers and data experts.

removing special characters

i'm reading from a database and found special character showing up as \0
or
�� when i serialize to xml.

trim does not work and using the string.Replace doesn't either.

how do i remove these?
Nov 13 '05 #1
2 32449
Mark Bosley <bo*********@hotmail.com> wrote:
i'm reading from a database and found special character showing up as \0
or
&#x0;&#x0; when i serialize to xml.

trim does not work and using the string.Replace doesn't either.

how do i remove these?


Trim should work just fine, as should string.Replace - could you give a
short but complete example of them not working? Here's one showing them
working:

using System;

public class Test
{
static void Main ()
{
string original = "hello\0 there\0\0\0";
string trimmed = original.Trim ('\0');
string replaced = original.Replace ("\0", "");

Console.WriteLine (original.Length);
Console.WriteLine (trimmed.Length);
Console.WriteLine (replaced.Length);
}
}

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 13 '05 #2
On Thu, 10 Jul 2003 12:11:03 -0700, "Mark Bosley"
<bo*********@hotmail.com> wrote:
i'm reading from a database and found special character showing up as \0
or
&#x0;&#x0; when i serialize to xml.

trim does not work and using the string.Replace doesn't either.

how do i remove these?
My guess is that you are calling it like this:

stringvar.Trim("\0");

However, in C#, strings are immutable, so that call actually returns a
new string. Call it like this:

stringvar=stringvar.Trim("\0");

'Lib


Nov 13 '05 #3

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

Similar topics

7
by: Roy W. Andersen | last post by:
I've been searching google about this for days but can't find anything, so I'm hoping someone here can help me out. I'm trying to create zip-files without needing the zip-file extension in PHP,...
2
by: Abby Lee | last post by:
I need to add and subtract transactions for each of our accounts within our Access DB for account reconciliation. Values found in our PdAmount field are either positive or negative. Positive...
1
by: Phil Amey | last post by:
In a web based form I am able to make sure that there is text in an input field but I want to restrict the user from using such characters as ~ # & ' How can I modify this JavaScript below to...
11
by: gopal srinivasan | last post by:
Hi, I have a text like this - "This is a message containing tabs and white spaces" Now this text contains tabs and white spaces. I want remove the tabs and white...
1
by: SStewart | last post by:
Does anyone know a good regex expression for removing all special characters from a string, allowing only alphanumeric?
5
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file"....
14
by: Harman Dhaliwal | last post by:
Hi, I am programming an in memory representation of a database and am at the tail end, hopefully, of implementation. But the vexing point is that my program runs fine with all my diagnostic...
1
by: sonald | last post by:
Dear All, I am working on a module that validates the provided CSV data in a text format, which must be in a predefined format. We check for the : 1. Number of fields provided in the text file,...
1
by: amitpatil | last post by:
Hello friends, I have a web form which holds fields containing special characters. On the next page when user submits those details, Information is shown with adding slashes to special...
3
KevinADC
by: KevinADC | last post by:
Purpose The purpose of this article is to discuss the difference between characters inside a character class and outside a character class and some special characters inside a character class....
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.