diff options
| author | nyamatongwe <unknown> | 2011-07-10 11:24:37 +1000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2011-07-10 11:24:37 +1000 | 
| commit | 683c2ca914f1987dfbeabca54db5b69ccb5c53e9 (patch) | |
| tree | 7983f602465c59ab31948833e990aa0a7cc0f842 | |
| parent | 3214eed6cb64d02cba6b90631a7013a872994bd6 (diff) | |
| download | scintilla-mirror-683c2ca914f1987dfbeabca54db5b69ccb5c53e9.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;    } | 
