Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved #4: Handles multi-byte characters with url-retrieve (i.e., without the external curl command) #29

Merged
merged 2 commits into from Apr 1, 2023

Commits on Mar 31, 2023

  1. Encode a lambda-provided API key as utf-8

    If the user provides the OpenAPI key via a function, as is the case by
    default if the user puts credentials in an auth-sources resource like
    .authinfo or .authinfo.gpg, then it is necessary to encode the
    function's returned value into utf-8 before passing it onward to build
    the HTTP request. This commit ensures that happen.
    
    Why is this necessary, given that the API key contains only
    alphanumeric characters and therefore should be byte-for-byte the same
    in utf-8 as in us-acii? I don't know. It may because emacs's
    url-http.el library concats many strings together, and they all need
    to be identically encoded before they can be combined correctly.
    
    Whatever the reason, this fix works and allows you to send prompts
    which include Unicode characters that require multibyte encodings in UTF-8
    algal committed Mar 31, 2023
    Copy the full SHA
    1ad773e View commit details
    Browse the repository at this point in the history
  2. Decode response body as utf-8 and then parse as json

    This changes response parsing so that the response body is decoded as
    UTF-8 and then parsed as JSON, rather than the other way around.
    
    This fixes the handling of responses that contain Unicode characters
    which are encoded with multiple bytes in UTF-8, such as emojis.
    algal committed Mar 31, 2023
    Copy the full SHA
    6d95b0e View commit details
    Browse the repository at this point in the history