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) :
Which procedure can be used to check whether its argument is a string?
Visually impaired? Let me spell it for you (wav file) download WAV