broken but halfway working input conversion
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3867 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
670567f9d4
commit
ebf4610ff0
@ -105,6 +105,36 @@ StyledEditView::GetStyledText(BPositionIO * stream)
|
||||
SetTextRect(textRect);
|
||||
}
|
||||
}
|
||||
if (fEncoding != 0) {
|
||||
CharacterSetRoster * roster = CharacterSetRoster::Roster(&result);
|
||||
if (result == B_OK) {
|
||||
uint32 id = roster->FindCharacterSetByFontID(fEncoding)->GetConversionID();
|
||||
SetText("");
|
||||
char inBuffer[256];
|
||||
off_t location = 0;
|
||||
int32 textOffset = 0;
|
||||
int32 state = 0;
|
||||
int32 bytesRead;
|
||||
while ((bytesRead = stream->ReadAt(location,inBuffer,256)) > 0) {
|
||||
location += bytesRead;
|
||||
char * inPtr = inBuffer;
|
||||
char textBuffer[256];
|
||||
int32 textLength = 256;
|
||||
int32 bytesConverted = bytesRead;
|
||||
while (textLength > 0) {
|
||||
convert_to_utf8(id,inPtr,&bytesConverted,textBuffer,&textLength,&state);
|
||||
InsertText(textBuffer,textLength,textOffset);
|
||||
textOffset += textLength;
|
||||
inPtr += bytesConverted;
|
||||
bytesRead -= bytesConverted;
|
||||
bytesConverted = bytesRead;
|
||||
if (textLength > 0) {
|
||||
textLength = 256;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fSuppressChanges = false;
|
||||
return result;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
virtual void SetEncoding(uint32 encoding);
|
||||
virtual uint32 GetEncoding() const;
|
||||
protected:
|
||||
virtual void InsertText(const char *text, int32 length, int32 offset, const text_run_array *runs);
|
||||
virtual void InsertText(const char *text, int32 length, int32 offset, const text_run_array *runs = NULL);
|
||||
virtual void DeleteText(int32 start, int32 finish);
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user