diff options
author | nyamatongwe <devnull@localhost> | 2011-07-10 11:24:37 +1000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2011-07-10 11:24:37 +1000 |
commit | 26c4afc7296f9e04d3ed37e07fb84c087a39fd64 (patch) | |
tree | 67291715348e75d1cc0994807883ca28adf2e434 | |
parent | e1b4c6ddc6e2a980a7ffbf7c3f81ffc929c234d0 (diff) | |
download | scintilla-mirror-26c4afc7296f9e04d3ed37e07fb84c087a39fd64.tar.gz |
Paste text into different encodings.
-rw-r--r-- | cocoa/ScintillaCocoa.mm | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index e097007c9..714fb93e2 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -1101,9 +1101,26 @@ bool ScintillaCocoa::GetPasteboardData(NSPasteboard* board, SelectionText* selec { if (selectedText != nil) { - char* text = (char*) [data UTF8String]; + CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(), + vs.styles[STYLE_DEFAULT].characterSet); + CFRange rangeAll = {0, [data length]}; + CFIndex usedLen = 0; + CFStringGetBytes((CFStringRef)data, rangeAll, encoding, '?', + false, NULL, 0, &usedLen); + + UInt8 *buffer = new UInt8[usedLen]; + + CFStringGetBytes((CFStringRef)data, rangeAll, encoding, '?', + false, buffer,usedLen, NULL); + bool rectangular = bestType == ScintillaRecPboardType; - selectedText->Copy(text, strlen(text) + 1, SC_CP_UTF8, SC_CHARSET_DEFAULT , rectangular, false); + + int len = usedLen; + char *dest = Document::TransformLineEnds(&len, (char *)buffer, len, pdoc->eolMode); + + selectedText->Set(dest, len+1, pdoc->dbcsCodePage, + vs.styles[STYLE_DEFAULT].characterSet , rectangular, false); + delete []buffer; } return true; } |