472,956 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,956 software developers and data experts.

problem with storing greek chars to a buffer (os linux)

hello everyone and happy new year.
i am not sure how to tackle this problem or where is originates from so
i am writing here in hope that if you can not help you can at least
point me in a direction.

I am writing some little program using only standard c++ library and i
am opening a file that contains strings. there are numbers , english
and greek letters among the characters. the reading is done fine and
the data are then stored onto a buffer (without undergoing any
processing) as a few int values ( the lengths of the strings), followed
by a long c string - the concatenation of all the strings of the file.
the receive application can then use the lengths of the strings to
separate the strings from the string again.

so examining the buffer contents in the shared memory i found that the
numbers have their correct corresponding values (0x30 for char '0'
etcetc.) and the lengths of the strings in the c string are correct
too. but the greek characters and system chars found among them (like
spacebar) where wrong - did not have their expected (extended) ascii
values. the funny thing is if i printf the strings of the file, they
appear correctly on console!!

i have set LC_ALL environment variable in my linux machine to
en_US.UTF-8, just in case this is an important detail. and the file was
written from vim (not internally from the program). is it possible that
the file is written in utf-16 format? utf-8? could it be something
wrong in the code?(see below)
thank you in advance for your help
CODE:
once i have the independent strings with 'loadInfoConf()' i serialise
them and send them to the shMem using:

string
detailsStr; details.writeStructToStream(GUILastMessage.oNL,GUI LastMessage.oTL,GUILastMessage.sNL,GUILastMessage. sLL,GUILastMessage.iDL,GUILastMessage.mDL,detailsS tr);
strcpy(&GUILastMessage.oAndS_str,detailsStr.c_str( ));
---------------------------------------------------------------
void InfoClass::loadInfoConf()
{
string curLine="",sumLine="", lines[6];
int i=0;

ifstream infoConfFile(INFOCONF_FILENAME);
if (infoConfFile.is_open())
{
while (!infoConfFile.eof())
{
getline(infoConfFile,curLine);
if ((curLine!="EOV"))
{
if (curLine!="")
sumLine=sumLine+curLine+"\n";
}
else
{
lines[i]=sumLine;
sumLine="";
i++;
}
}
infoConfFile.close();

//remove the last char which is always \n due to the way
//the file open parser (just above) works
lines[0].erase( (lines[0].length()-1) ,1);
lines[1].erase( (lines[1].length()-1) ,1);
lines[2].erase( (lines[2].length()-1) ,1);
lines[3].erase( (lines[3].length()-1) ,1);
lines[4].erase( (lines[4].length()-1) ,1);
lines[5].erase( (lines[5].length()-1) ,1);

info.operatorTel = lines[0];
info.operatorName = lines[1];
info.stationNum = lines[2];
info.stationLoc = lines[3];
info.instDate = lines[4];
info.maintDate = lines[5];

}
else
cout<<"could not open info file\n";
}
------------------------------------------------------------------------------------
void InfoClass::writeStructToStream (int &on_len, int &ot_len, int
&sn_len, int &sl_len, int &id_len, int &md_len, string &buffer)
{
on_len=info.operatorName.length();
ot_len=info.operatorTel.length();
sn_len=info.stationNum.length();
sl_len=info.stationLoc.length();
id_len=info.instDate.length();
md_len=info.maintDate.length();

//int totLen=on_len+ot_len+sn_len+sl_len+id_len+md_len/*+1*/;
string tmpbuf="";
tmpbuf += info.operatorTel;
tmpbuf += info.operatorName;
tmpbuf += info.stationNum;
tmpbuf += info.stationLoc;
tmpbuf += info.instDate;
tmpbuf += info.maintDate;

buffer=tmpbuf;
}
-------------------------------------------------------------------------

Jan 3 '07 #1
0 1384

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

Similar topics

8
by: Xela | last post by:
Hi A have a very annoying problem. I have written java strored procedures for DB2 v8.1. Their deployement and usage is fine as long as the server is a Windows one. But under Solaris 8 and Linux...
0
ekekakos
by: ekekakos | last post by:
Hello, I am having a serious and urgent problem with the character settings of an oracle database. The database is sitting in a solaris unix server and when we run the env command we have the...
6
by: pros | last post by:
Hi, I am new to learning how to program in JavaScript and want to design a program in JavaScript that will allow a user to run a Classical Greek vocabulary flashcard program on my web page. My...
2
by: Lupus | last post by:
Hi everyone, I've got a problem with a piece of javascript code which parses a string. The problem occurs when the string contains some special characters like é, è, ü... There are 2 symptoms...
0
by: kiluone | last post by:
Hi forums, we can't seem to find the answer to this issue. I hope someone can point me in the correct direction. " we are passing text values entered by user to PHP from Flash using XML. But...
4
by: alexjcollins | last post by:
The following program demonstrates the problem: #include <vector> #include <iostream> #include <tvmet/Vector.h> typedef tvmet::Vector<double, 3Vector3d; class Mesh {
12
by: Punkis | last post by:
Hi all, I have a problem with my php and mysql project. I use an auctions software, named phpauction for my project. I import into my database with utf8 encodingm and I can see the greek...
2
by: Graham Benney | last post by:
Greetings How do I put a non ascii character on a PyQt pushButton? I have tried things like txt = u"\u03a0" (Should be a Greek sigma symbol) but all it shows is the literal string u\03a0. I am...
2
by: stelios andread | last post by:
I'm writing a java programme, which connects to a database in my computer(using jdbc). The database is allowed to use greek characters and I can check that, because when I use a "select" query, the...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.