git-svn-id: svn://db.shs.com.ru/pip@208 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
6
main.cpp
6
main.cpp
@@ -31,12 +31,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
int main (int argc, char * argv[]) {
|
int main (int argc, char * argv[]) {
|
||||||
PIFile::setDefaultCharset("utf8");
|
|
||||||
piCout << PIFile::defaultCharset();
|
|
||||||
PIFile::setDefaultCharset("cp1251");
|
|
||||||
piCout << PIFile::defaultCharset();
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
VC<30, double> x(1.5), y(3.3);
|
VC<30, double> x(1.5), y(3.3);
|
||||||
double r = 0.0;
|
double r = 0.0;
|
||||||
PITimeMeasurer tm;
|
PITimeMeasurer tm;
|
||||||
|
|||||||
@@ -193,6 +193,19 @@ PIString PIString::fromAscii(const char * s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PIString PIString::fromCodepage(const char * s, const char * c) {
|
||||||
|
int l = 0;
|
||||||
|
while (s[l] != '\0') ++l;
|
||||||
|
PIString ret;
|
||||||
|
if (l > 0) ret.appendFromChars(s, l
|
||||||
|
#ifdef PIP_ICU
|
||||||
|
, c
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIString::buildData(const char * cp) const {
|
void PIString::buildData(const char * cp) const {
|
||||||
data_.clear();
|
data_.clear();
|
||||||
#ifdef PIP_ICU
|
#ifdef PIP_ICU
|
||||||
|
|||||||
@@ -731,7 +731,10 @@ public:
|
|||||||
|
|
||||||
//! \brief Return string constructed from ASCII
|
//! \brief Return string constructed from ASCII
|
||||||
static PIString fromAscii(const char * s);
|
static PIString fromAscii(const char * s);
|
||||||
|
|
||||||
|
//! \brief Return string constructed from "c" codepage
|
||||||
|
static PIString fromCodepage(const char * s, const char * c);
|
||||||
|
|
||||||
//! \brief Return string contains human readable size in B/kB/MB/GB/TB
|
//! \brief Return string contains human readable size in B/kB/MB/GB/TB
|
||||||
//! \details Example: \snippet pistring.cpp PIString::readableSize
|
//! \details Example: \snippet pistring.cpp PIString::readableSize
|
||||||
static PIString readableSize(llong bytes) {PIString s; s.setReadableSize(bytes); return s;}
|
static PIString readableSize(llong bytes) {PIString s; s.setReadableSize(bytes); return s;}
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ bool PIFile::closeDevice() {
|
|||||||
|
|
||||||
|
|
||||||
PIString PIFile::readLine() {
|
PIString PIFile::readLine() {
|
||||||
PIString str;
|
PIByteArray str;
|
||||||
if (!opened_) return str;
|
if (!opened_) return str;
|
||||||
int cc;
|
int cc;
|
||||||
while (!isEnd()) {
|
while (!isEnd()) {
|
||||||
@@ -188,8 +188,12 @@ PIString PIFile::readLine() {
|
|||||||
if (char(cc) == '\n' || cc == EOF) break;
|
if (char(cc) == '\n' || cc == EOF) break;
|
||||||
str.push_back(char(cc));
|
str.push_back(char(cc));
|
||||||
}
|
}
|
||||||
|
str.push_back('\0');
|
||||||
|
if (defaultCharset()) {
|
||||||
|
return PIString::fromCodepage((const char *)str.data(), defaultCharset());
|
||||||
|
}
|
||||||
//cout << "readline: " << str << endl;
|
//cout << "readline: " << str << endl;
|
||||||
return str;
|
return PIString(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user