473,395 Members | 1,647 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,395 software developers and data experts.

little endian

CTG

var x = "B113769A"

How do you convert B113769A to "9A7613B1" to get the proper
conversion ?
Jun 27 '08 #1
2 2213
RobG wrote on 22 mei 2008 in comp.lang.javascript:
On May 22, 11:09 am, CTG <BadMul...@gmail.comwrote:
>var x = "B113769A"
// Return if has invalid characters
if (/[^a-f0-9]/.test(x.toLowerCase())) return;
if ( /[^a-f0-9]/i.test(x) ) return;
// Might need left padding
x = (x.length % 2)? '0'+x : x;

// Split into an array of pairs, reverse and join again
return x.match(/../g).reverse().join('');
Nice! Will remember that one.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 27 '08 #2
On May 22, 5:09*pm, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
RobG wrote on 22 mei 2008 in comp.lang.javascript:
On May 22, 11:09 am, CTG <BadMul...@gmail.comwrote:
var x = "B113769A"
* // Return if has invalid characters
* if (/[^a-f0-9]/.test(x.toLowerCase())) return;

if ( /[^a-f0-9]/i.test(x) ) return;
Ah yes...
>
* // Might need left padding
* x = (x.length % 2)? '0'+x : x;
* // Split into an array of pairs, reverse and join again
* return x.match(/../g).reverse().join('');

Nice! Will remember that one.
Credit where credit's due - the inspiration came from the second
banana example here:

<URL: http://www.merlyn.demon.co.uk/js-valid.htm#JS >
--
Rob
Jun 27 '08 #3

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

Similar topics

2
by: hicham | last post by:
Hi, I am looking for help, i would like to know how can i use the endian.h and config.h to convert compiled files under solaris from BIG-ENDIAN to compiled files LITTLE-ENDIAN. I am working...
3
by: gary | last post by:
Hi, 1. About all C/C++ compilers, Does stack increase from high address to low address and heap grow increase from low to high? What on earth decides their increase direction, CPU architecture, OS...
8
by: Perception | last post by:
Hello all, If I have a C-like data structure such that struct Data { int a; //16-bit value char; //3 ASCII characters int b; //32-bit value int c; //24-bit value }
2
by: bhatia | last post by:
Hello all, If I have a C-like data structure such that struct Data { int a; //16-bit value char; //3 ASCII characters int b; //32-bit value int c; //24-bit value }
5
by: manishster | last post by:
I keep getting the following in my output file , regardless of whether I convert endian-ness or not . How do i get "01 02 03 04" .... Mahamannu output : 04 03 02 01 b0 00 00
3
RRick
by: RRick | last post by:
This was a question that showed up in a job interview once. (And to answer your next question: No, I didn't :)) Write a subroutine that returns a bool on whether a system supports big endian...
6
by: Javier | last post by:
Hello people, I'm recoding a library that made a few months ago, and now that I'm reading what I wrote I have some questions. My program reads black and white images from a bitmap (BMP 24bpp...
23
by: guthena | last post by:
Write a small C program to determine whether a machine's type is little-endian or big-endian.
2
by: Ramesh | last post by:
Hi I have a structure as below on big endian based system typedef struct { unsigned long LedA:5; unsigned long LedB:4; unsigned long LedC:8;
23
by: Niranjan | last post by:
I have this program : void main() { int i=1; if((*(char*)&i)==1) printf("The machine is little endian."); else printf("The machine is big endian."); }
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...

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.