Hi All,
I am facing some problem with basic file operation...
I have one xml file looks like
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<x:recording>
<udf3>Gélin</udf3>
</x:recording>
My code is like it will read this file and store it into one string
and will call one Database Stored procedure to parse the xml and store
it into some tables.
eg:
FILE * file = fopen("testFile .xml","r+b");
struct _stat buffer;
int result1 = _stat( "testFile.x ml", &buffer );
int size = buffer.st_size;
char *temp = new char [(sizeof(char))* (size+1)];
fread(temp,size of(char),size,f ile);
pass this temp to Ado for SP execution.
Problem:
you can see the xml file has one higherorderASCI I character' é '
this going to the SP as wrong character 'é '
While debugging the code as well I can see the temp is having this
wrong value.
I reading in the binary mode but still why this problem is happening.
Can you please help me to resolve that 4 1868 ra************* **@yahoo.co.in wrote:
Hi All,
I am facing some problem with basic file operation...
I have one xml file looks like
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<x:recording>
<udf3>Gélin</udf3>
</x:recording>
My code is like it will read this file and store it into one string
and will call one Database Stored procedure to parse the xml and store
it into some tables.
eg:
FILE * file = fopen("testFile .xml","r+b");
struct _stat buffer;
int result1 = _stat( "testFile.x ml", &buffer );
int size = buffer.st_size;
char *temp = new char [(sizeof(char))* (size+1)];
As we are in the C world, that should be malloc - and sizeof(char) is by
definition, 1.
fread(temp,size of(char),size,f ile);
pass this temp to Ado for SP execution.
What is Ado and SP? Without knowing what is called, it's difficult to
answer the question.
>
Problem:
you can see the xml file has one higherorderASCI I character' é '
this going to the SP as wrong character 'é '
What happens if you use unsigned char? Does the function you are
calling expect ASCII or UTF8, char, unsigned char or something else?
--
Ian Collins. ra************* **@yahoo.co.in wrote:
I have one xml file looks like
<?xml version=3D"1.0" encoding=3D"UTF-8" standalone=3D"n o" ?>
^^^^^^^
There's your problem.
you can see the xml file has one higherorderASCI I character' =E9 '
No, it doesn't.
this going to the SP as wrong character '=C3=A9 '
This is what is actually in the file.
Read up on UTF-8. It's a way of encoding Unicode, including characters
_above_ 0xFF (such as Devanagari and other Indian scripts, which may be
one reason why the person who supplied your file uses it), in sequences
of 8-bit bytes. This does mean that all over 0x7F must be encoded in two
or more bytes. Either just pass on the UTF-8, or decode it by hand; it's
not hard. The greatest problem is going to be deciding what to do when
(not if!) you do get a Unicode character that won't fit in your C char.
Richard
On Apr 12, 1:22 pm, r...@hoekstra-uitgeverij.nl (Richard Bos) wrote:
ramyakrishnaku. ..@yahoo.co.in wrote:
I have one xml file looks like
<?xml version=3D"1.0" encoding=3D"UTF-8" standalone=3D"n o" ?>
^^^^^^^
There's your problem.
you can see the xml file has one higherorderASCI I character' =E9 '
No, it doesn't.
this going to the SP as wrong character '=C3=A9 '
This is what is actually in the file.
Read up on UTF-8. It's a way of encoding Unicode, including characters
_above_ 0xFF (such as Devanagari and other Indian scripts, which may be
one reason why the person who supplied your file uses it), in sequences
of 8-bit bytes. This does mean that all over 0x7F must be encoded in two
or more bytes. Either just pass on the UTF-8, or decode it by hand; it's
not hard. The greatest problem is going to be deciding what to do when
(not if!) you do get a Unicode character that won't fit in your C char.
Richard
File is getting written by another routine , where all the characters
are written using fwrite.
In that header is been hard coded as "<?xml version="1.0"
encoding="UTF-8" standalone="no" ?"
I think this conversion of characters is happening after writteninto
the file right?
Can we change anything[changing any other format of xml] while writing
the xml file, which will store these without conversion?
In reading code, how will it come to know these wto characters are
belongs to one character. or is there any other decoding machanism.
I am not much familiar with the xml.
I tried reading with unicode wide char as well, but it was not reading
properly. ra************* **@yahoo.co.in wrote:
On Apr 12, 1:22 pm, r...@hoekstra-uitgeverij.nl (Richard Bos) wrote:
ramyakrishnaku. ..@yahoo.co.in wrote:
I have one xml file looks like
<?xml version=3D"1.0" encoding=3D"UTF-8" standalone=3D"n o" ?>
^^^^^^^
There's your problem.
you can see the xml file has one higherorderASCI I character' =E9 '
No, it doesn't.
this going to the SP as wrong character '=C3=A9 '
This is what is actually in the file.
Read up on UTF-8. It's a way of encoding Unicode,
File is getting written by another routine , where all the characters
are written using fwrite.
In that header is been hard coded as "<?xml version="1.0"
encoding="UTF-8" standalone="no" ?"
I think this conversion of characters is happening after writteninto
the file right?
How the blazes should _I_ know? _You_ have access to (possibly even
written) this "routine", whether that mean function or whatever, I do
not.
In reading code, how will it come to know these wto characters are
belongs to one character. or is there any other decoding machanism.
My dear boy, if you won't do your own research, you'll never amount to a
programmer. Information on UTF-8 is extremely easy to come by.
Richard This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Xah Lee |
last post by:
# -*- coding: utf-8 -*-
# Python
# to open a file and write to file
# do
f=open('xfile.txt','w')
# this creates a file "object" and name it f.
# the second argument of open can be
|
by: Lionel B |
last post by:
Greetings,
I need to read (unformatted text) from stdin up to EOF into a char
buffer; of course I cannot allocate my buffer until I know how much
text is available, and I do not know how much text is available until I
have read it... which seems to imply that multiple reads of the input
stream will be inevitable.
Now I can correctly find the number of characters available by:
|
|
by: Oliver Knoll |
last post by:
According to my ANSI book, tmpfile() creates a file with wb+ mode
(that is just writing, right?). How would one reopen it for reading?
I got the following (which works):
FILE *tmpFile = tmpfile();
/* write into tmpFile */
...
|
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen. It is
almost like it is trying to implement it's own COM interfaces...
below is the header, and a link to the dll+code:
Zip file with header, example, and DLL:...
|
by: John Dann |
last post by:
I'm trying to read some binary data from a file created by another
program. I know the binary file format but can't change or control the
format. The binary data is organised such that it should populate a
series of structures of specified variable composition.
I have the structures created OK, but actually reading the files is
giving me an error. Can I ask a simple question to start with:
I'm trying to read the file using the...
| |
by: AdrianH |
last post by:
Assumptions
I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming.
FYI
Although I have called this article “How to Parse a File in C++”, we are actually mostly lexing a file which is the breaking down of a stream in to its component parts, disregarding the syntax that stream contains. Parsing is actually including the syntax in order to make...
|
by: Atran |
last post by:
Hello:
In this article: You will learn to Write or Read A Text File.
Let's Begin:
First Create a new project (ConsoleApp or WinApp).
And Make sure your program uses these namespaces:
using System;
using System.IO;
using System.Diagnostics;
|
by: Zach |
last post by:
I compiled a game client and it crashed (segmentation fault) resulting
in a core file being generated. I'm trying to find out exactly what
caused it to crash. Any ideas how I can do this with gdb? In the
Makefile can I just add a "-g" flag to have the binary produced with
debugging symbols? The source is written in ANSI C.
This is what I have now:
"CC = gcc"
The client binary is 433680 and the core file produced when it crashed
|
by: dwaterpolo |
last post by:
Hi Everyone,
I am trying to read two text files swY40p10t3ctw45.col.txt and solution.txt
and compare them, the first text file has a bunch of values listed like:
y
y
y
y
y
y
y
|
by: rohit |
last post by:
Hi All,
I am new to C language.I want to read integers from a text file and
want to do some operation in the main program.To be more specific I
need to multiply each of these integers with another set of integers
stored in an array.It would be a great help if you could provide some
code for it.I tried the function fscanf but by that I am able to read
only the first integer of the text file.Please help me.
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |