get wide character and multibyte character value


,


I need to know the wide character (unicode) and multibyte (UTF-8)
values of a character string of czech. I personally know nothing about
czech. Is the following approach correct

1. I use L on the character string and watch memory to get the wide
character representation of the character string in little endian
form;

2. I change the computer region/language to czech, and use function
WideCharToMultiByte, and use CP_ACP as input code page and use the L
character string as input to get the output multibyte character string
output from parameter lpMultiByteStr.

Is (1) and (2) correct Any more efficient and smart ways


Posted On: Sunday 4th of November 2012 10:39:00 PM Total Views:  219
View Complete with Replies

RELATED TOPICS OF C Language PROGRAMMING LANGUAGE




Code getting Crashed( C++)

On Aug 7, 11:00 pm, Erik Wikstrm wrote: > On 2008-08-07 11:39, Pallav singh wrote: > > std::auto_ptr CreateNew_PizzaProduct() > > { pizza.reset(new Pizza()); } > > Actually I'm surprised your code crashes, because it should not even > compile. In the above function you forgot to return a value. The above code need not generate a compiler diagnostic. Furthermore, no code 'should not compile' unless it contains a #error directive. The behaviour is undefined if the function is actually called.
VIEWS ON THIS POST

237

Posted on:

Sunday 4th November 2012
View Replies!

How to call a function by a string of name & How to get the name of aclass?

---------------------------This is my task:-------------------------------------- There are hundred of similar classes and a large file(in processing) with thousand of instances of these classes. I should export these instances into a XML file (I use Tiny XML), however not total instances, but these which belong to the selected classes and the selected attributes(member variable and value). In advance, I will have a configuration file (also XML format), to define which classes and which attributes we need, that is a user-defined file. The problem are: 1, How do I get the name of a class Just like by Java the method .getclass() or instanceof 2, Is it possible to have such as an iterator to traverse through all the variables/functions, to only call the functions and to get the values of variables we need by name Thank you very much for your reply, indeed.
VIEWS ON THIS POST

234

Posted on:

Sunday 4th November 2012
View Replies!

Simple problem, don't get it

Hi , I am self studyign "Essential c++" which gives the following problem and code. I don't get the code: the condition in the while statement uses cin, but shouldsn't you input a variable using cin and then use it with the while loop Also how does cin>>while satisfy the problem i tried running the code as given, and with a value assigned to ival, but it doesn't work. Write a program to read in a sequence of integers from standard input. Place the values, in turn, in a built-in array and a vector. Iterate over the containers to sum the values. Display the sum and average of the entered values to standard output. #include #include using namespace std; int main() { vector ivec; int ival; while (cin >> ival) ivec.push_back(ival); // we could have calculated the sum as we entered the // values, but the idea is to iterate over the vector ... for (int sum = 0, ix = 0; ix < ivec.size(); ++ix) sum += ivec[ix]; int average = sum / ivec.size(); cout
VIEWS ON THIS POST

211

Posted on:

Sunday 4th November 2012
View Replies!

Copy constructor doesn't get called when initialized by functionreturning object of same class

I am bit puzzled at the following piece of code I tried: ---------------------------------------------------------------------------------- #include using namespace std; class Test { public: Test() { cout
VIEWS ON THIS POST

282

Posted on:

Sunday 4th November 2012
View Replies!

[winapi] how to get signal from microphone in winapi?

Could someone explain me how to get signal from microphone to program in winapi, (than i want put tone [ctcss] into it) and send to speakers
VIEWS ON THIS POST

252

Posted on:

Sunday 4th November 2012
View Replies!

Openwatcom C++ ,g3d graphics libraries& wxWidget

I am new to uses of C++ programming. I will appreciate by heart , help to me to complete my work as: 1. Use of openwatcom C++ latest compiler v1.7a http://www.openwatcom.org/index.php/Download 2.Use of wxwidget in GUI ,wXMain for windows 2.8.7 http://www.wxwidgets.org/downloads/ 3.Use of free graphics 3d libaries is "G3D" v7.0 C++tool kit. http://g3d-cpp.sourceforge.net/manual/index.html 4. I wish to use & edit demos from G3D website. I want to use installation on Crive Request to help me how to install,setting of paths,drives for installation,environment variables,compilation of wX & G3D for openwatcom.
VIEWS ON THIS POST

198

Posted on:

Sunday 4th November 2012
View Replies!

can I get some help

I'n new hear < and I'm really sory about my bad language > I wont some help in making tic tac toe code in c I have a code witch could be usefull >> but I want to make sure that I understand it >> it should use minimax and heurastic algorithm so if some one could help me >> and sea if the coul using heurestic ..................................................................................................... #include #include /* the functions */ void theboard(void); void playgame(int play, char who); int boardfull(void); int win(int who); void computermove(int who); void humanmove(int who); void output(void); int minimax(int who); int bestminimaxmove(int a[9],int who); int board[3][3]; /* Main function */ int main(void) { int play; char c, who; clrscr(); printf("Tic Tac Toe !\n"); do { /* the board */ theboard(); /* to play */ printf("typ 1 to play or 2 to exit game !"); while ((play=getchar()-48)2); if (play==1) { printf("Who goes first (Computer or Human)"); while((who=toupper(getchar()))!='C' && who!='H'); } clrscr(); playgame(play,who); clrscr(); /* final output */ output(); /* Determine who won or if it was a game over and output */ if (win(-1)) { if(who=='C')printf("\nThe Computer won\n"); else if(who=='H')printf("\nPlayer won\n"); } else if (win(1)) { if(who=='C')printf("\nPlayer won\n"); else if(who=='H')printf("\nThe Computer won\n"); } else printf("\nIt game over.\n"); /* asking for another game */ printf("\nWould you like to play again\n"); while ((c=toupper(getchar()))!='N' && c!='Y'); } while(toupper(c)=='Y'); } /* theboard sets all of the values in the board to 0 */ void theboard() { int i,j; for(i=0;i
VIEWS ON THIS POST

312

Posted on:

Sunday 4th November 2012
View Replies!

Problem with gethostbyname - can't find any!

jonashn wrote: > I have the following visual c++ code. It's taken from Beej's guide to > network programming, and modified a little foruse with winsock. But > gethostbyname just doesn't work, not for localhost nor any other ala > http://google.com > CODE: > > #include "stdafx.h" > #include > #include > [..] > > Do you see any problems with the above code You mean, beyond the fact that it's non-standard C++ > I'm nearly 100% sure the > error isn't caused by my local machine. Then it's caused by something else. > When running it like client.exe localhost it gives the Winsock error > code 11001 aka host not found. > > Any suggestions Post to the newsgroup where Winsock is on topic, like the Windows programming newsgroup, there are several. The FAQ contains the list of the proposed ones. V -- Please remove capital 'A's when replying by e-mail I do not respond to top-posted replies, please don't ask
VIEWS ON THIS POST

236

Posted on:

Sunday 4th November 2012
View Replies!

get memory size for STL containers

, How can I determine how much memory is used by various STL containers For example, I have a vector, I know that an int takes 4B and I have 10 elements in my vector. So, I know that that my vector will take at least 40B, but I would like to know more exactly. I would like to know how much more does the vector needs for its stuff. I also need to know the memory size for set and map (unordered_map).
VIEWS ON THIS POST

167

Posted on:

Sunday 4th November 2012
View Replies!

gmake error: No rule to make target lib_file.a

Hi all!!! I have been trying to port a piece of C++ code from windows to Linux environment. I'm using redhat9 which has KDE3 and QT3.1.x on it. I used KDevelop 2.1 bundled with it. I created a new C++ project with KDevelop. The code needs to import headers and .a files containing the definitions of functions contained therein. I supplied the path of the folder containing the headers as "-Ipath_of_header_folder" as a compiler flag and supplied the path of library files' folder as "- Lpath_of_lib_folder" as a linker flag. Then I mentioned the names of the libraries that need to be linked with the code in the linker options->additional libraries. I have used -Wall compiler flag. The code is compiling properly but when I hit make, the compiler is throwing up the following error: gmake[3]: *** No rule to make target `lib_file.a,', needed by `project_name'. Stop. Seems something is wrong with the make options but I haven't changed any of the defaults.. Please Help!!!
VIEWS ON THIS POST

185

Posted on:

Sunday 4th November 2012
View Replies!

how to get available physical memory on unix

hi, on window we can GlobalMemoryStatusEx() to get the memory status on the system do we have any equivalent function on Unix/linux can we use BOOST library to memory information on the unix please help me.
VIEWS ON THIS POST

154

Posted on:

Sunday 4th November 2012
View Replies!

getting current timestamp

I want to find the current time stamp in micro sec precision. The requirement is, my function is executed in an infinite loop. I measure a value and check if the value computed is what i expected 9forget all this stuff). I want to print the time stamp every time that event occurs. So my requirement is printing the current timestamps. so I can calculate the average time (in micro secs) after which such an event occur... I hope I made my requirement clear. Can anybody pls help me with this problem. I searched many discussion but couldn't find satisfactory answer.
VIEWS ON THIS POST

197

Posted on:

Sunday 4th November 2012
View Replies!

virtual function in inherited class not getting called

I have a base class CEventSelect a bit like this: class CEventSelect { virtual void OnConnected(); } and a network interface class a bit like this: class networkinterface : public CEventSelect { virtual void OnConnected(); } The base CEventSelect class calls it's OnConnected() function when a client receives notification from the network that it is connected. But I wanted my networkinterface::OnConnected() method to be called But it wasn't. I understand polymorphic functions and I think I understand why it is not working the way I wanted. Because CEventSelect calls its own OnConnected() method does mean that the inheriting OnConnected() will be called. But this is the behaviour I want. The actual connection is notified by the base class - but I want my interface class to someone get notified of the connection. How can I get the networkinterface class to be notified about the connection
VIEWS ON THIS POST

197

Posted on:

Sunday 4th November 2012
View Replies!

vector, get index from iterator

Seems odd, but I was wondering if I am in the middle of iterating through a vector, is there a way to calc which index I am currently on something like: it - vec.begin() I don't want to change the loop to iterate through using indexes instead of iterators, I just need the index for a little debug output, the rest of the code in the loop uses the iterator.
VIEWS ON THIS POST

179

Posted on:

Sunday 4th November 2012
View Replies!

Operator () overloading, wrong overload gets called

On Sep 10, 8:35 am, fabian....@gmail.com wrote: > Im having a problem with my code. Im programming a vector > class, and am trying to overload the () operator in 2 > different situations. The first situation is to assign > values, e.g. Y = X(1,2), the elements 1 and 2 of X gets > assigned to Y. In this case, the operator () overload should > create a copy that is unmodifiable. In the 2nd case, I want do > assign values to elements 1 and 2, e.g. X(1,2) = Y. Then in > this case, the values must be updated. I update by > instantiating a custom iterator class which has an overloaded > = operator. Below is my code. Sorry its a little long. > The issue now is that when I do Y = X(1,2), I always end up > calling the overload that is meant for the 2nd situation, > rather than the first. I hope I can get some advice. I've not plunged into your code, but the standard solution here is for the operator() to return a proxy. (I did something like this in my pre-standard string class, which allowed: s( n, m ) = ... ; for s = s.replace( n, m, ... ) ; ..) Basically, you still need two operator(): one const (in order to be able to call it on a const object), and one non-const. The const one can return the sub-vector directly, but the non-const one must return a proxy. Basically, the proxy just stores the relevant information, and overloads its operator= so that it actually does the expected assign. Something like: class Proxy // should be a member of Vector { public: Proxy( Vector& v, int i, int j ) : owner( &v ), i( i ), j( j ) { } // For conversion to rvalue... operator Vector() const { return Vector( *owner, i, j ) ; } // For v1 = v2( i, j ) ; Vector& operator=( Vector const& other ) { owner->v.erase( v.begin() + i, v.begin() + j ) ; owner->v.insert( v.begin() + i, other.begin(), other.end() ) ; return *owner ; } } ; Or something along those lines. -- James Kanze (GABI Software) email:james.kanze@gmail.com 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
VIEWS ON THIS POST

342

Posted on:

Sunday 4th November 2012
View Replies!

How to get a reverse_iterator

Simple question, how to get a reverse_iterator As you can see from the following code, I managed to answer the first half of the question myself, but can't figure out the second half: string line("FIRST,MIDDLE,LAST"); // find first element in a comma-separated list string::iterator comma = find(line.begin(), line.end(), ','); cout
VIEWS ON THIS POST

156

Posted on:

Sunday 4th November 2012
View Replies!

How to get the CPU Usage of other applications? Thanks

Language: C++, tool: Borland C++ Builder 4.0 I have tried to search in the Internet, and found that i can use WMI, here is an example from Internet: private void timer1_Tick(object sender, System.EventArgs e) { ManagementObjectSearcher search = new ManagementObjectSearcher("Select * from Win32_PerfRawData_PerfOS_Processor where Name='0' "); foreach(ManagementObject info in search.Get()) { decimal PercentProcessorTime=0; ulong u_newCPU = (ulong)info["PercentProcessorTime"]; ulong u_newNano = (ulong)info["TimeStamp_Sys100NS"]; decimal d_newCPU = Convert.ToDecimal(u_newCPU); decimal d_newNano = Convert.ToDecimal(u_newNano); decimal d_oldCPU = Convert.ToDecimal(u_oldCPU); decimal d_oldNano = Convert.ToDecimal(u_oldNano); PercentProcessorTime = (1 - ((d_newCPU-d_oldCPU)/(d_newNano - d_oldNano)))*100m; u_oldCPU = u_newCPU; u_oldNano = u_newNano; this.Text = PercentProcessorTime.ToString("N"); //\t\t\t\t\t\t\t } } but i am writing Borland C++ Builder program, so i wrote: GetWmiInfo(Memo1->Lines, "select * from win32_PerfFormattedData_PerfProc_Process where name = 'explorer"); void GetWmiInfo(TStrings *lpList, WideString wsClass) { IWbemLocator *pWbemLocator = NULL; if(CoCreateInstance(CLSID_WbemAdministrativeLocator, NULL, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER, IID_IUnknown, (void**)&pWbemLocator) == S_OK) { IWbemServices *pWbemServices = NULL; WideString wsNamespace = (L"root\\cimv2"); if(pWbemLocator->ConnectServer(wsNamespace, NULL, NULL, NULL, 0, NULL, NULL, &pWbemServices) == S_OK) { IEnumWbemClassObject *pEnumClassObject = NULL; WideString wsWQL=L"WQL", wsQuery= wsClass;// WideString(L"Select * from ")+wsClass; if(pWbemServices->ExecQuery(wsWQL, wsQuery, WBEM_FLAG_RETURN_IMMEDIATELY,NULL, &pEnumClassObject) == S_OK) { IWbemClassObject *pClassObject = NULL; ULONG uCount = 1, uReturned; if(pEnumClassObject->Reset() == S_OK) { int iEnumIdx = 0; while(pEnumClassObject->Next(WBEM_INFINITE, uCount, &pClassObject, &uReturned) == S_OK) { lpList->Add("---------------- ["+IntToStr(iEnumIdx) +"] -----------------"); SAFEARRAY *pvNames = NULL; if(pClassObject->GetNames(NULL, WBEM_FLAG_ALWAYS | WBEM_MASK_CONDITION_ORIGIN, NULL, &pvNames) == S_OK) { long vbl, vbu; SafeArrayGetLBound(pvNames, 1, &vbl); SafeArrayGetUBound(pvNames, 1, &vbu); for(long idx=vbl; idxGet(bs, 0, &vValue, NULL, 0); SysFreeString(bs); if(hRes == S_OK) { AnsiString s; Variant v = *(Variant*)&vValue; if(v.IsArray()) { for(int i=v.ArrayLowBound(); iAdd(AnsiString(wsName)+"="+s); } VariantClear(&vValue); SysFreeString(wsName); } } if(pvNames)SafeArrayDestroy(pvNames); iEnumIdx++; } } if(pClassObject)pClassObject->Release(); } if(pEnumClassObject)pEnumClassObject->Release(); } if(pWbemServices)pWbemServices->Release(); } if(pWbemLocator)pWbemLocator->Release(); } But i found that the value TimeStamp_Sys100NS i get is NULL, so i cannot make a calculation like the example one, can anyone tell me why
VIEWS ON THIS POST

123

Posted on:

Sunday 4th November 2012
View Replies!

Strong exception safety guaranty - Did I forget something ?

Alf P. Steinbach a crit : > The above operator= should work nicely, but is too complicated for my > taste. > > I'd just use the usual swap idiom,
VIEWS ON THIS POST

216

Posted on:

Sunday 4th November 2012
View Replies!

In std C++,How to get the Current time?

>> And Is there any class or method to manipulate Date or Time In standard C++ -------Thank all
VIEWS ON THIS POST

121

Posted on:

Sunday 4th November 2012
View Replies!

string as getline delimiter

all, what shoudl I do if my delimiter has more than one character Also is it possible to have 2 different delimiters
VIEWS ON THIS POST

247

Posted on:

Sunday 4th November 2012
View Replies!