1
//========================================================================
7
// Copyright 2005 Albert Astals Cid <aacid@kde.org>
9
//========================================================================
14
#include "goo/GooString.h"
15
#include "PDFDocEncoding.h"
16
#include "UGooString.h"
18
UGooString::UGooString(Unicode *u, int l)
24
UGooString::UGooString(GooString &str)
26
if ((str.getChar(0) & 0xff) == 0xfe && (str.getChar(1) & 0xff) == 0xff)
28
length = (str.getLength() - 2) / 2;
29
s = (Unicode *)gmallocn(length, sizeof(Unicode));
30
for (int j = 0; j < length; ++j) {
31
s[j] = ((str.getChar(2 + 2*j) & 0xff) << 8) | (str.getChar(3 + 2*j) & 0xff);
37
UGooString::UGooString(const UGooString &str)
40
s = (Unicode *)gmallocn(length, sizeof(Unicode));
41
memcpy(s, str.s, length * sizeof(Unicode));
44
UGooString::UGooString(const char *str)
50
void UGooString::initChar(GooString &str)
52
length = str.getLength();
53
s = (Unicode *)gmallocn(length, sizeof(Unicode));
54
bool anyNonEncoded = false;
55
for (int j = 0; j < length && !anyNonEncoded; ++j) {
56
s[j] = pdfDocEncoding[str.getChar(j) & 0xff];
57
if (!s[j]) anyNonEncoded = true;
61
for (int j = 0; j < length; ++j) {
62
s[j] = str.getChar(j);
67
UGooString::~UGooString()
72
int UGooString::cmp(UGooString *str) const
79
for (i = 0, p1 = s, p2 = str->s; i < n1 && i < n2; ++i, ++p1, ++p2) {
88
char *UGooString::getCString() const
90
char *res = new char[length + 1];
91
for (int i = 0; i < length; i++) res[i] = s[i];