Welcome to the CHICKEN Scheme pasting service

converting scheme string to wchar_t array added by caolanm on Mon Jul 24 14:41:00 2017

(define (string->wchar src)
  (let* ((orig-size (+ (string-length src) 1))
         (wchar-length (mbstowcs #f (location src) 0)))
    (if (< wchar-length 0)
        (abort (make-property-condition
                'exn
                'location 'string->wchar
                'message "Invalid multibyte sequence has been encountered"))
         (let* ((dest-wchar-size (+ wchar-length 1))
                (dest (make-blob (* dest-wchar-size wchar-size)))
                (converted (mbstowcs (location dest) (location src) dest-wchar-size)))
           dest))))


(define (wchar->string wstr)
  (let* ((dest (make-string (+ (blob-size wstr) 1)))
         (converted (wcstombs (location dest) (location wstr) (string-length dest))))
    (string-take dest converted)))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Type in the text below:
 _           _                  _    
| | ____   _| | __ _  __ _  ___| | __
| |/ /\ \ / / |/ _` |/ _` |/ __| |/ /
|   <  \ V /| | (_| | (_| | (__|   < 
|_|\_\  \_/ |_|\__, |\__, |\___|_|\_\
                  |_||___/           
Visually impaired? Let me spell it for you (wav file) download WAV