diff options
author | culler <culler> | 2020-05-17 22:25:49 (GMT) |
---|---|---|
committer | culler <culler> | 2020-05-17 22:25:49 (GMT) |
commit | e1536be3400277b049bebfe6c91b24db95b93cbf (patch) | |
tree | ba504c59e6f15925eb9c51d3a4869b9d3c03d55a /macosx/tkMacOSXPrivate.h | |
parent | 882b73c3b4629cc5952a334d74433efdf966b317 (diff) | |
parent | 8fe8aab16504c4e9b91e295e0ee2a537797d0316 (diff) | |
download | tk-e1536be3400277b049bebfe6c91b24db95b93cbf.zip tk-e1536be3400277b049bebfe6c91b24db95b93cbf.tar.gz tk-e1536be3400277b049bebfe6c91b24db95b93cbf.tar.bz2 |
Simplify Aqua text handling by moving encoding/decoding into the TKNSString class.
Diffstat (limited to 'macosx/tkMacOSXPrivate.h')
-rw-r--r-- | macosx/tkMacOSXPrivate.h | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 38b438f..a80ba83 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -306,10 +306,6 @@ MODULE_SCOPE int TkMacOSXServices_Init(Tcl_Interp *interp); MODULE_SCOPE int TkMacOSXRegisterServiceWidgetObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -MODULE_SCOPE NSString* TkUtfToNSString(const char *source, size_t numBytes); -MODULE_SCOPE int TkUtfAtIndex(NSString *string, int index, char *uni, - unsigned int *code); -MODULE_SCOPE char* TkNSStringToUtf(NSString *string, int *numBytes); MODULE_SCOPE unsigned TkMacOSXAddVirtual(unsigned int keycode); #pragma mark Private Objective-C Classes @@ -522,17 +518,16 @@ VISIBILITY_HIDDEN * * When Tcl is compiled with TCL_UTF_MAX = 3 (the default for 8.6) it cannot * deal directly with UTF-8 encoded non-BMP characters, since their UTF-8 - * encoding requires 4 bytes. - * - * As a workaround, these versions of Tcl encode non-BMP characters as a string - * of length 6 in which the high and low UTF-16 surrogates have been encoded - * using the UTF-8 algorithm. The UTF-8 encoding does not allow encoding - * surrogates, so these 6-byte strings are not valid UTF-8, and hence Apple's - * NString class will refuse to instantiate an NSString from the 6-byte - * encoding. - * - * This subclass of NSString adds a new initialization method which accepts - * a C string encoded with the scheme described above. + * encoding requires 4 bytes. Instead, when using these versions of Tcl, Tk + * uses the CESU-8 encoding internally. This encoding is similar to UTF-8 + * except that it allows encoding surrogate characters as 3-byte sequences + * using the same algorithm which UTF-8 uses for non-surrogates. This means + * that a non-BMP character is encoded as a string of length 6. Apple's + * NSString class does not provide a constructor which accepts a CESU-8 encoded + * byte sequence as initial data. So we add a new class which does provide + * such a constructor. It also has a DString property which is a DString whose + * string pointer is a byte sequence encoding the NSString with the current Tk + * encoding, namely UTF-8 if TCL_MAX >= 4 or CESU-8 if TCL_MAX = 3. * *--------------------------------------------------------------------------- */ @@ -543,6 +538,7 @@ VISIBILITY_HIDDEN NSString *_string; } @property const char *UTF8String; +@property (readonly) Tcl_DString DString; - (instancetype)initWithTclUtfBytes:(const void *)bytes length:(NSUInteger)len; @end |