In short - what is the JavaScript for Mac Automation equivalent of AppleScript\'s as «class utf8»
?
I have a unicode string that I\'m t
If you want to ensure your file gets written with UTF8 encoding, use NSString's writeToFile:atomically:encoding:error
function, like so:
fileStr = $.NSString.alloc.initWithUTF8String( 'your string here' )
fileStr.writeToFileAtomicallyEncodingError( filePath, true, $.NSUTF8StringEncoding, $() )
You would think that writing an NSString object initialized from a UTF8 string would get written out as UTF8 but I've found from experience that writeToFile:atomically
does not honor the encoding of the string being written out. writeToFile:atomically:encoding:error
explicitly specifies which encoding to use. On top of that, writeToFile:atomically
has been deprecated by Apple since OS X 10.4.