Get encoding name
|

|
Hi everybody,
Would anybody of you please tell me how can I know the encoding name
of a file with in which I saved a text file
Like - I saved a file with name "test.text" and encoding unicode.
I want to extract "unicode" or whatever we take encoding while saving. |
|
Posted On: Monday 5th of November 2012 02:01:46 AM |
Total Views:
415 |
View Complete with Replies
|
|
RELATED TOPICS OF C Language PROGRAMMING LANGUAGE
|
|

|
|

|
|

|
My application has a small JNI piece written in C++. This piece was
developed using VC++ 2k5. We statically link with some .lib's which
were built using vc6. I see that exceptions thrown by some api's in
these .lib's are not getting caught but are causing the app to crash.
When this code was "ported" to vc6 this wasn't observed. It so happens
we also support HPUX n Solaris n it works fine there too. Why's this
happening |

|
VIEWS ON THIS POST
176
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
hi,
i have come aross a strange problem with a bit of code that uses a
ostringstream to build up a string and i extract the string into a
user buf via the sgetn() call instead of via the str() method.
however, it appears that when the contents extracted via sgetn() are
invalid for the first extract.
below is a test prog that demonstrates the issue. we are using Forte
7.0 on solaris 5.8; i dont have access to gcc (or any other c++
compiler). can someone tell me where i'm going wrong
thanks
ray
#include
#include
#include
#include
#include
using namespace std;
int main(int argc, char* argv[])
{
try
{
ostringstream dump;
size_t sz = 0;
if (argc == 1) {
dump sgetn(tmp, 4);
tmp[4] = NULL;
dump.seekp(0);
// this comes out as empty string!!!
cout |

|
VIEWS ON THIS POST
172
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
I have an simple MFC dialog based application. On launch of that
application 'Password protected screen saver' is not getting activated
after the screen saver timeout.
If 'On resume, password protect' option unchecked, I am getting the
Screen saver.
Application not generating any of the keyboard or any user events to
disturb the system. If I exit the application every thing works
normal(Means password protected screen saver gets activates after
screen saver time out period.)
Please help me in understanding, why 'Password protected screen saver'
is not getting activated. |

|
VIEWS ON THIS POST
285
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
there,
I am writing a C++ wrapper for different underlying xml libraries. In
order to minimize the use of pointers, i provide a class template to
wrap an xml node object pointer, using the pimpl idiom:
template
class basic_xml_node {
typedef basic_xml_node node_type;
public:
...
// copy constructor: accept a non-const RHS
basic_xml_node(node_type& rhs): pimpl_(rhs.pimpl_) { }
// copy assignment: accept a non-const RHS
node_type& operator=(node_type& rhs) {
pimpl_ = rhs.pimpl_;
return *this;
}
// non-const member function.
void set_localname(std::string const& localname) {
pimpl_->set_localname(localname);
}
...
private:
boost::shared_ptr pimpl_;
};
The copy constructor accepts a non-const RHS to avoid the following
misuse:
typedef basic_xml_node xml_node;
void foo(xml_node const& node) {
xml_node copy = node;
copy->set_localname("toto");
}
Since the basic_xml_node class template holds a pimpl to the real xml
node object, if its copy constructor/assignment accepts a const RHS,
the code above will compile and run, and the effect is that the local
name of the const node reference parameter will be changed after the
function call. If the copy constructor/assignment accepts a non-const
RHS, the code above will no longer compile (which is what i expect).
Unfortunately, when i use the class template, VC++ complains a lot on
"nonstandard extension used" (warning C4239). Details:
conversion from basic_xml_node to
basic_xml_node&: A reference that is not to 'const'
cannot be bound to a non-lvalue.
I think such warnings are benign, but even if the warning id is
disabled in my xml header files, such warnings still appear in client
code, as long as the client code uses (implicitly) the copy
constructor or copy assignment.
I know that std::auto_ptr class template has the same problem. So i
just would like to know if there is a way to get rid of this warning
I do not want to disable this warning globally, or turn down the
warning level. |

|
VIEWS ON THIS POST
153
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
Greetings,
I have been trying to teach myself C++ over the past few weeks and
have finally came across a problem I could not fix. I made a simple
program that prints out a square or rectangle using the * character.
The program was just for practice but I am having problems.
My main problem is, in my program I use 4 functions to change or
access two variables in my code. The variables are
itsHeight;
itsWidth;
The functions are
getHeight(), getWidth()
and
setHeight(), setWidth()
Now for some reason the value that gets stored in itsHeight and
itsWidth goes haywire and saves an astronomically huge number. It
makes my square huge to where you cant see it on a screen and takes a
long time to print. If I move the two variables outside of the class
and make them global, they work like normal. I know I must be doing
something wrong.
I am also having problems creating prototypes of my functions. I could
not create a prototype of my functions that needed to access my
Rectangle class. I was forced to define all the functions above the
Main and then define an object for each one. I was sure there was a
way to use prototypes so you could define your function later, but
somehow force the function to recognize my class ahead of time. Does
this make sense Right now only my menu function has a prototype. I
know defining a function before main is perfectly fine and that making
a prototype makes no difference but for the sake of learning, and the
sake of organization any help would rock!
The programs not done and there might be a few things in here that I
am not using at the very moment. That stuff should be commented out. I
also have not defined my variables very well between INT, Unsigneds,
longs and shorts. This is because I had it all nice and neatly
organized to what I think I would need for each function, but then
when I hit this brick wall I started changing them to INT to see if it
would make a difference. I will go back and make the appropriate
changes when I know what im doing wrong. Please lend advise to a newb!
#include
using namespace std;
//Define Variable types
typedef unsigned short int USI;
typedef unsigned long int ULI;
enum BOOL {FALSE, TRUE};
enum uchoose {print=1, area, perimeter, resize, salir};
//declare rectangle class
class Rectangle {
private: //Private Class Variables
int itsWidth;
int itsHeight;
public: //Public Variables and Functions
ULI printArea(){return itsHeight*itsWidth;}
ULI printPerimeter(){return itsHeight*2+itsWidth*2;}
int getHeight() const {return itsHeight;}
int getWidth() const {return itsWidth;}
int setHeight(int);
int setWidth(int);
};
int Rectangle::setHeight(int h) {
itsHeight=h;
}
int Rectangle::setWidth(int w) {
itsWidth=w;
}
void getMenu();
int printRect() {
Rectangle rect;
int h=rect.getHeight(),w=rect.getWidth();
for (USI x=0; x |

|
VIEWS ON THIS POST
197
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
Hi
I have good C++ knowledge, but would like to get perfect by study and then
get a certification. What is best (online/mail) certication Where can I do
tests for it (online/mail) What is the most respectable certification Does
it have to be Microsoft certification How about Visual C++, object oriented
programming certifications |

|
VIEWS ON THIS POST
190
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
Given the following program:
#include
class FG
{
public:
explicit FG( std::locale const& l )
: myLoc( &l ) {}
template< typename F >
operator F const&() const
{
return get< F >( *myLoc, &std::use_facet ) ;
}
private:
std::locale const* myLoc ;
template< typename F >
F const& get( std::locale const& l,
F const& (*f)( std::locale const& ) ) const
{
return (*f)( l ) ;
}
} ;
FG
getF( std::locale const& l )
{
return FG( l ) ;
}
void
f()
{
std::ctype< char > const& ct = getF( std::locale() ) ;
}
G++ (4.1.0) instantates the template operator F const& to get
the const reference needed to call the copy constructor (which
of course fails to compile, since use_facet is not legal).
Providing a non-template:
operator FG const&() const { return *this ; }
solves the problem, but is g++ correct here I would have
expected the temporary "FG( l )" to bind directly to the const
reference of the (compiler generated) copy constructor.
Or maybe my question is: is this intentional Given 8.5.3/5,
"[...]If the initializer expression [...]-- has a class type [it
does] and can be implicitly converted to an lvalue of type "cv3
T3", where "cv1 T1" is reference-compatible with "cv3 T3" [...]
then [...] the reference is bound to the lvalue result of the
conversion [...]" But it doesn't seem at all natural to have a
user defined conversion called for a copy.
--
James Kanze (GABI Software) mailto:james.kanze
Conseils en informatique oriente objet/
Beratung in objektorientierter Datenverarbeitung
9 place Smard, 78210 St.-Cyr-l'cole, France, +33 (0)1 30 23 00 34
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |

|
VIEWS ON THIS POST
154
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
Here is a small program. It's meant to keep reading lines from the
stdin till someone types the (really cute) string "manchu". In that
case it breaks out of the loop and the program terminates.
///////////////////////////////////
#include
#include
using namespace std;
int main() {
string str;
char ch;
while ( cin ) {
cin.clear();
cin.ignore( cin.rdbuf()->in_avail() );
getline( cin, str, '\n');
if ( str == "manchu" )
break;
if ( cin.eof() || cin.fail() ) {
cin.clear();
}
}
return 0;
}
I am compiling this with gcc 3.3.1 on Solaris 9 SPARC, and with gcc
3.2.3 on RHEL 3.
Now here is the crux. I wanted that if the user just typed "Ctrl+D",
it should clear the eof and fail bits and continue the loop looking
for more input. It does this nicely on Linux but goes into an infinite
loop on Solaris sparc, repeatedly encountering EOF. I am guessing that
this is a wrong piece of code
and somehow it is working in one case, and not in the other case.
And hoping that someone actually points out where I am going wrong.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |

|
VIEWS ON THIS POST
146
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
I'm a C/C++ old-timer. My last C++ was writing the book Learn C++
Today! (Don't blame me for the title.) One of my best books, by the
way. Heartily recommended to all who think there's a future in MS-DOS
programming.
Before the world went totally GUI, I went totally Java, so I don't
know basics like how to launch a window, how to populate a form, etc.
I have a project now that I plan to do in C. Can someone recommend a
good (re)starting point
I'm using Linux (KDE), but would like to support Gnome and Windows,
too. |

|
VIEWS ON THIS POST
135
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
If input date in format "yyyymmdd", how to determinate the weekday
i.e If input 20070228, which function can return "Wed"
Thank you.. |

|
VIEWS ON THIS POST
123
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
I'm trying to do line-at-a-time command interpreter input under eCos using
an fstream for a serial port (/dev/tty1). The fstream has a 256-byte
filebuf, and it's doing 256-byte fread() calls underneath. However, even
though fread() gets a short read from the underlying device when I hit
Enter, it goes back and reads more, until it gets the full 256 bytes--which
perversely seems to be what the C standard requires it to do.
Is getline() generally supposed to work as one would expect on interactive
devices Is one expected to do a setvbuf on it, either to disable
buffering,
or to supply a one-character buffer I've tried both of these under eCos,
and neither works, but I wouldn't be a bit surprised if eCos's
implementation of fstreams, or for that matter the C stdio library, is
buggy.
--
Ciao, Paul D. DeRocco
Paul mailtoderocco@ix.netcom.com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |

|
VIEWS ON THIS POST
154
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
.
I have some problems with cin. Here's the code: http://rafb.net/p/GhK3AU65.html
If you press '6', and 'enter', it will have to ask for another insert of
a string. However, in this case, it goes straight without waiting for
input... any ideas |

|
VIEWS ON THIS POST
139
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
,
I've got one here I just don't understand. The problem isn't with SQL
syntax or anything related to the database system, but I wanted to give
that info so that you would understand why the string is formatted like
so.
Ok, I have code that ultimately is trying to build a string that looks
like this:
INSERT INTO table (col1, col2, col3, col4, col5) VALUES ('data col1',
2, 3, '1/3/2007',
'Misc data' );
Now, in my code, the string is built like this:
// assume the below function is a class member with data members
// std::string insStr
// std:stringstream int2char
void BuildInsString( std::string& d1, int d2, int d3, std::string& d4 )
{
insStr += "INSERT INTO table (col1, col2, col3, col4, col5) VALUES
(";
insStr += "'"; insStr += d1; insStr += "', ";
int2char |

|
VIEWS ON THIS POST
162
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
Hi ,
I have following dumping function and use it for dumping data to files:
int Dump(FILE* file, char* string)
Everything goes ok, but this time I need to dump my data
into standard output, standard error, ect.
Where can I get the proper pointer to FILE structure
or how should I initialize this structure correctly
Thanx
N. |

|
VIEWS ON THIS POST
138
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
here is my problem
void resumeGame(userData & loadInfo)
{
cout |

|
VIEWS ON THIS POST
175
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
Subject: How can I get the input stream in commandline application
Hi !
I have to get the input stream in my win32 commandline application.
Using another words, I want to catch content of input stream file
given like this:
myapp.exe < data.txt
How can I do it |

|
VIEWS ON THIS POST
221
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
I'm new to C, coming from perl. Essentially, i'm fairly new to
programming in every way, shape and form.
One project that I continually work on, just to help me get used to
writing, is code that finds primes. This is my first try porting it to
C, and I can't seem to get it to execute properly.
Everything compiles fine, but the program, when executed, will
continue past when I think it should exit. Can anyone point me in the
right direction
/* Prime Number Counter */
/* Attempt Number 1 */
/* Andrew Levenson */
/* 02.07.2007. */
/* Libraries */
#include /* Standard Library */
#include /* For sqrt function */
/* Definitions */
/* Body */
int main()
{
int i = 3, j;
Prime_Test(i, j);
return 1;
};
int Prime_Test(i, j)
{
while(i |

|
VIEWS ON THIS POST
147
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
Hi all,
I am trying to overload the < operator, but get warning
class Windowinfo
{
protected:
HWND wndhandle; //the window handle
int wndId; //the window Id
public:
Windowinfo();
Windowinfo(const Windowinfo &wnd);
friend bool operator |

|
VIEWS ON THIS POST
166
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
Hi ,
Is there any way of getting the size of any ADT or simple data type
like int etc without using sizeof
And how does the sizeof() function work |

|
VIEWS ON THIS POST
149
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|
|

|
Hi people,
I know that getenv() returns the value of single environment variable,
but I need some function that returns all of env. variables
(just like when we type SET in commandline or similar). |

|
VIEWS ON THIS POST
146
|

|
Posted on:
Monday 5th November 2012
|
View Replies!
|
|

|