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

Script that reads formatting marks

code green
1,726 Expert 1GB
Does anybody know of a test editor or a useful script that can view the 'invisible' formatting marks in a text file.

Line breaks in particular cause me huge problems when csv and xml files are passed between different companies and systems, most certainy Unix and Windows.

I would like to read the ASCII character that is actually there not what Microsft thinks is there.

I know this is not really PHP, but I don't know where it belongs.
Jan 7 '11 #1
5 1276
Rabbit
12,516 Expert Mod 8TB
You mean like a hex editor?
Jan 7 '11 #2
code green
1,726 Expert 1GB
Yes, a hex editor would be alright.
Do you know of one, or do I have write my own?
Jan 10 '11 #3
HaLo2FrEeEk
404 256MB
Probably write your own, I don't know of any, though I'm sure some exist. If you know exactly which formatting marks you want to look for you could simply str_replace those with their hex equivalent. If you want to be able to view all characters as their hex values, you could iterate through the string like this:

Expand|Select|Wrap|Line Numbers
  1. $str = "test";
  2.  
  3. for($i = 0; $i < strlen($str); $i++) {
  4.   echo str_pad(dechex(ord($str[$i])), 2, "0", STR_PAD_LEFT)." ";
  5.   }
This outputs:

74 65 73 74

The hex equivalent of the string "test".

First you're getting the decimal (ASCII) value of the character, then you're getting the hex value from the decimal value, and just for safety, padding the string to a length of 2 with a "0" character, since, for example, a decimal value of 5 will display as 5 in PHP, but it's actual hex value is 05. The padding is just in case there are any characters whose decimal value is less than or equal to 16 (which is 0F in hex).

Edit: Also, if you want, you can wrap that in strtoupper(). This isn't really necessary, since the hex byt 0f is the same as 0F, but it just adds a uniformity.
Jan 11 '11 #4
Rabbit
12,516 Expert Mod 8TB
I use Hex Editor Neo. They have a free version that has a smaller feature set but is good enough for light use.
Jan 11 '11 #5
code green
1,726 Expert 1GB
Part of the probem is formatting marks that are missing,
in particular carriage returns so str_replace doesn't help here.
I need this mainly for debugging script generated files, such as CSV and XML that are being sent via FTP.
I will have a look at Neo.
Thanks for the suggestions
Jan 11 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: melih.onvural | last post by:
Group, I want to get into a remote server, tail a file, and see if the last line is an error or not. I think that I've figured out how to shell over and tail the file. I have the specific server...
2
by: Woekaah | last post by:
Hi, is there anybody who knows a script that loads the index.html frameset when a separate page from that frameset is loaded? I did have it yesterday but deleted it because it wasn't configured...
16
by: Douglas | last post by:
Gday, How would I format a number so that: TheValue = 32500 Displays in the TextBox as: $32,500.00
2
by: Colleyville Alan | last post by:
I am using Access and have embedded the ActiveX control Formula One that came with Office 2000. (ver 3.04). I have created and formatted a spreadsheet and now I want to copy the info with...
3
by: DS | last post by:
I have a Field that reads #Error, sometimes...I want to use conditional formatting to hide the field when it reads #Error...so in conditional formatting I put - when field equals "#Error" , but it...
3
by: rvanvolken | last post by:
After sending an email message formatted for HTML using the STMP Mail function within .NET, my message arrives with exclamation marks throughout the text, which inadvertantly hinders the correct...
8
by: Bob Sanderson | last post by:
I am relatively new to PHP and MySQL. This is the first time I've tried to use multiple queries in a single script. I have the following PHP script which gets a Job Number from a search form and...
9
by: sck10 | last post by:
Hello, I have a page with an ImageButton that is used to redirect to another page. When the page first opens, everything looks as expected. However, when I click on the image, the new page...
0
by: shaker | last post by:
While using the Visual Studio Code Editor, I somehow accidentally managed to turn on the display of formatting marks (such as tabs, spaces, and carriage returns). How do I turn this off? Thanks....
1
by: hansoffate | last post by:
Hi, The first part of my script works fine. Basically, the script reads a file with IDs that I want to search from a Flatdatabase and pull information. I setup the a TILDA Delimitted File...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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.