473,756 Members | 3,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Remove square character

I need to remove a square character from a text file. How can I locate a
square character and remove it?

Thanks.
Mark
Nov 21 '05 #1
3 9890
Mark wrote:
I need to remove a square character from a text file. How can I locate a
square character and remove it?

Thanks.
Mark


Define "square character" are you referring to any character that is
not human readable?

Step 1. Read in one Character
Step 2. Check if Character is in your allow list. (You can use
Char.IsDigit and such)
Step 3. Store the character whereever you want.

Chris
Nov 21 '05 #2
"Mark" <mn******@neb.r r.com> wrote in message
news:uK******** ********@TK2MSF TNGP10.phx.gbl. ..
I need to remove a square character from a text file.
How can I locate a square character and remove it?


No idea which is the "square" character, but here's a fragment to
trash all the spaces :

Dim reader as New System.IO.Strea mReader( "file" )
Dim sData as String _
= reader.ReadToEn d()
reader.Close()

sData = sData.Replace( " ", "" )

Dim writer as New System.IO.Strea mWriter( "file", False )
writer.Write( sData )
writer.Close()

And yes; it /does/ read the entire file into a String, do a Replace and
write the whole lot back again; even in the Brave New World that is
(or was) ".Net", you /still/ can't zap and reshuffle individual bytes in a
sequential disk file directly - which is probably a Good Thing ;-)

HTH,
Phill W.
Nov 21 '05 #3

"Mark" <mn******@neb.r r.com> wrote in message
news:uK******** ********@TK2MSF TNGP10.phx.gbl. ..
:
: I need to remove a square character from a text file. How can I
: locate a square character and remove it?
:
: Thanks.
: Mark
We need more context than this before we can give you a meaningful
answer, but very often unreadable (i.e.: control) characters are
rendered as boxes in some text readers. I'm assuming that is what you
are looking at in which case remove any characters that have an ASCII
value less than 32 (space). On approach (and not necessarily the best
for your needs) would be:

Dim s As String = <some value containing control chars>
Dim ndx As Integer
Dim c As Char

With New System.Text.Str ingBuilder
For ndx = 1 To Len(s)
c = Mid(s, ndx, 1)
If Asc(c) < 32 Then
.append(c)
End If
Next
s = .ToString
End With


Nov 21 '05 #4

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

Similar topics

2
3145
by: Clint Olsen | last post by:
Hello: I posted a thread on comp.programming awhile back asking about an algorithm I implemented on square root. The idea was to use the square root of a prime number as a convenient way to get a pseudorandom number generator. So, rather than calculate the square root to try to get a particular precision answer, you would calculate it to x number of bits. This particular function takes a radicand and the number of iterations as...
7
22594
by: Steve | last post by:
string str ="\"C:\Program Files\Internet Explorer\iexplore.exe\" -nohome" How can I remove charcter to string str = ="C:\Program Files\Internet Explorer\iexplore.exe -nohome"
4
4257
by: Spencer H. Prue | last post by:
Hello, I am trying to print a unicode character that's in Japanese. In my ASP.NET app (C#) I just set a char to that unicode character and use a response.write(). The char prints, but it is just a square. I set the culture of the .aspx page to japanese, and even though my browser already prints asian characters, I added the Japanese to it also. My web config has the utf-8 line in it. What should I do? Thanks,
6
18407
by: Daniel Mark | last post by:
Hello all: I have the following snippet: In : fileName = 'Perfect Setup.txt\n' In : fileName = fileName # remove the '\n' character In : fileName Out: 'Perfect Setup.txt'
3
2948
by: balakrishnan.dinesh | last post by:
Hi frnds, Im having a problem in searching out a particular substring in a string. Here the code: --------------------- <html> <script> var tmpString=" ";
9
4006
by: Smiley | last post by:
Hi, Can someone tell me how to remove aspostophe (') from user input. I don't want to give any error message. Just want to remove or change it to "" or null, such input when it appear anywhere on a specific field. e.g. if user input abcd's. I want the final data on the database be look like abcds or abcd s MSAccess 2000
2
4609
by: Edan | last post by:
Hello I'm trying to remove square brackets and everything between them from a string, using regular expressions I know how to use preg_replace, and know the basics of regex, but can't success. Can anyone please give me a regex for it? Thanks in advance! Edan
3
2032
by: JWest46088 | last post by:
Hello everybody. I'm having a little trouble using recursion. I need to accept input from the user and display the input in a square. It has to be done recursively. I would be able to do it without using recursion (although it may not be the best way and sloppy), but I cannot for the life of me figure out how to do it using recursion. Here is how it's supposed to work: Enter characters: lucky //ask for user input ...
5
13974
tharden3
by: tharden3 | last post by:
How do I remove white space around an icon? I have been using some helpful icon pics from google images to spice up a website that I'm making. In many instances though, the icon is not square, but irregularly shaped, leaving white space to make a square around the icon. In one case, I was using a 16 x 16 gif image of a movie reel (a round object) but I could not get rid of the white space around the object. How can I do this?
0
9456
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10034
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9713
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.