473,770 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP Binary data transformation

Hello,

I'm using ADODB.Stream to open a binary file on the server and write
it down to the browser using Response.Binary Write. It's working fine,
but i need to make some changes to the binary data before it is send
to the browser.

I'm trying to use REPLACE, but it's not finding a string that i know
it's in the binary file. Using InstrB i've found that the search
inside the binary data is being done in a Unicode format, but i don't
know how to make an ascii search&replace operation on binary data.

I'd greatly appreciate any help, cause i'm blocked.

thanks,
ferran
Jul 19 '05 #1
1 6310
Ferran,

Just to make sure I'm clear --- you need an ASCII file on the client,
and is the server binary also ASCII?

I think there are a couple of ways to go. If it is a text file, you
could convert to a Unicode string on the server, do your string
manipulation and then convert back. You could also save as a text
file on the server and provide a hyperlink rather than doing a binary
write.

If you really need to do a binary write, then I think you need to just
do string manipulation by using InstrB. One approach would be to get
the index of the content to replace, build a string byte by byte up to
it, add the new content and then build a string byte by byte from the
remaining content.

In VB you can do something like this:

myString = ""
For intCounter = 1 To intIndexOfRepla cedContent
myString = myString & Chr(AscB(MidB(s trWebFileText, intCounter,
1)))
Next

For intCounter = 1 To Len(strWebFileT ext)
myString = myString & Chr(AscB(MidB(s trWebFileText, intCounter,
1)))
Next

For intCounter = 1 To Len(strWebFileT ext) -
intIndexAfterRe placedContent
myString = myString & Chr(AscB(MidB(s trWebFileText, intCounter4,
1)))
Next

Then you need to call a function to convert the resulting unicode
string to ASCII. Michael Kaplan posted code to do this --- he has a

WtoA functing in a module called inCodePage. I've re-posted below,
but again this is his code, not mine.

'--------------------------------
' WToA
'
' UNICODE to ANSI conversion, via a given codepage
'--------------------------------
Public Function WToA(ByVal st As String, Optional ByVal cpg As Long =
-1, Optional lFlags As Long = 0) As String
Dim stBuffer As String
Dim cwch As Long
Dim pwz As Long
Dim pwzBuffer As Long
Dim lpUsedDefaultCh ar As Long

If cpg = -1 Then cpg = GetACP()
pwz = StrPtr(st)
cwch = WideCharToMulti Byte(cpg, lFlags, pwz, -1, 0&, 0&, ByVal 0&,
ByVal 0&)
stBuffer = String$(cwch + 1, vbNullChar)
pwzBuffer = StrPtr(stBuffer )
cwch = WideCharToMulti Byte(cpg, lFlags, pwz, -1, pwzBuffer,
Len(stBuffer), ByVal 0&, ByVal 0&)
WToA = Left$(stBuffer, cwch - 1)
End Function
---------------------------------------------------------

I haven't tested this, but something like this should work.

Hope it helps,
Mark
Hello,

I'm using ADODB.Stream to open a binary file on the server and write
it down to the browser using Response.Binary Write. It's working fine,
but i need to make some changes to the binary data before it is send
to the browser.

I'm trying to use REPLACE, but it's not finding a string that i know
it's in the binary file. Using InstrB i've found that the search
inside the binary data is being done in a Unicode format, but i don't
know how to make an ascii search&replace operation on binary data.

I'd greatly appreciate any help, cause i'm blocked.

thanks,
ferran

Jul 19 '05 #2

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

Similar topics

9
9720
by: Maurizio Penna | last post by:
I, guys. I've embeded an image into a xml file, something like that: <display type="picture" mime="image/png" name = "mosaico6.png"> <!]> </display> Now, I want to display it with a XSL Transformation, but my code don't work: <display>
2
7098
by: hipo | last post by:
Hi: I'm trying to read data from Navision 2.60 ERP with own database to a SQL Server 2000 database via ODBC. All is working except just one thing, how to filter data with a date field. I have some big tables that have a date field and I just want to read data from one or few days, not all the table, cos I will be doing this every day (datawarehousing).
103
48760
by: Steven T. Hatton | last post by:
§27.4.2.1.4 Type ios_base::openmode Says this about the std::ios::binary openmode flag: *binary*: perform input and output in binary mode (as opposed to text mode) And that is basically _all_ it says about it. What the heck does the binary flag mean? -- If our hypothesis is about anything and not about some one or more particular things, then our deductions constitute mathematics. Thus mathematics may be defined as the subject in...
1
4312
by: cfyam | last post by:
How can I transfer Excel data to Sql Server?
3
1520
by: The unProfessional | last post by:
I'm having difficulty figuring out a simple way to dump unmanaged structure and/or class data to binary files. In standard C++: -------------------------- typedef struct tagS1 { DWORD dwBlah; CHAR szBlah; } S1;
26
4319
by: Patient Guy | last post by:
Has anyone written code that successfully manipulates binary file data using Javascript? It might---and in the case of doing I/O, will---make use of browser- specific functions (ActiveX/COM with Internet Explorer, XPCOM/XPConnect with Mozilla/Firefox). I am writing client-side code that will generate binary data for producing a GIF file through an OBJECT element. (The GIF is an image of a line and points on a two-axis plot.)
6
2591
by: young_leaf | last post by:
Using STL how do I convert a variable to a binary string but with special case which for example BYTE x, i need only the first 3 bits of this byte, is that possible? to be more specific, from that byte i want to generate (so valid values for x will be 0-5) 000 001
22
2299
by: QQ | last post by:
Hi I have a unsigned char array, but I need to compress it in the bit level. for instance the array is 0x91,0x92,0x93.... I need to change it into a bit stream like 10010001 10010010 10010011 .... and operate this stream bit by bit and transform it into another bit stream, and convert that bit stream into an unsigned char array. How can I do it? Thanks a lot!
1
3902
by: AK | last post by:
Hello, I'm trying to create an XML digital signature over some assets listed in the XML file. It works fine until I add a pdf file in the list of assets, which throws an exception saying that "Data at the root level is invalid". I'm sure it must be possible to sign binary files as well, but I've been searching for hours and can't find any examples. Hope someone can help me with this. Here's the code I'm using:
0
9618
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
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
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
10101
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9906
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...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
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

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.