myuhe / org-gcal.el

Org sync with Google Calendar
450 stars 113 forks source link

Support unicode #78

Open larstvei opened 7 years ago

larstvei commented 7 years ago

Hi! Thanks for this very cool package!

It seems like non-ASCII characters are ignored when syncing with google calendar.

If I place the following text in the org file I synchronise with google calendar:

* Test: å
  <2017-02-03 Fri 19:00>

Then it is replaced by the following after synchronisation:

* Test: 
  :PROPERTIES:
  :LINK: [[https://www.google.com/calendar/event?eid=djhmMG5zMmZpbnVyYm9haTZuMnNyYnA1Z2sgbGFyc3R2ZWkyQG0][Go to gcal web page]]
  :ID: v8f0ns2finurboai6n2srbp5gk
  :END:

  <2017-02-03 Fri 19:00>

Notice that the å have been removed.

I will try to look into it, but if you could point me in the right direction, that would be great!

bgschaid commented 7 years ago

I had the same issue to (with umlauts). Is it possible that the reason for this is that in org-gcal--json-read the encoding in utf-8 is enforced? According to https://stackoverflow.com/questions/8872493/setting-file-encoding-for-org-mode-ical-export (didn't look for the original source) Google expects cp1252

codemac commented 7 years ago

I get lots of encoding errors on my sync'd calendars, where it asks me to choose the encoding to save files as and replace symbols that aren't in it. Is this similar to what's experienced here?

11111000000 commented 7 years ago

My report (russian utf-8): First, it correctly imports the data available in the calendar, however, if I make changes - add синхронизация word to title, for example, the last ones are displayed as A8=E@>=870F8O (in google calendar interface too)

labe-me commented 7 years ago

So we should patch this part of the code to fix the encoding ?

https://github.com/myuhe/org-gcal.el/blob/master/org-gcal.el#L627

Wouldn't google be happy if we add something like "charset=utf-8" in the Content-Type header ?

https://github.com/myuhe/org-gcal.el/blob/master/org-gcal.el#L626

torgeir commented 7 years ago

Adding charset=utf-8 still removes e.g. æ, ø and å for me. This however, seems to keep them..


(defun org-gcal--post-event (start end smry loc desc &optional id a-token skip-import skip-export)
  (let ((stime (org-gcal--param-date start))
        (etime (org-gcal--param-date end))
        (stime-alt (org-gcal--param-date-alt start))
        (etime-alt (org-gcal--param-date-alt end))
        (a-token (if a-token
                     a-token
                   (org-gcal--get-access-token))))
    (request
     (concat
      (format org-gcal-events-url (car (car org-gcal-file-alist)))
      (when id
        (concat "/" id)))
     :type (if id "PATCH" "POST")
-    :headers '(("Content-Type" . "application/json"))
+    :headers '(("Content-Type" . "application/json;charset=cp1252"))

Still does not work for arbitrary unicode, like e.g. emojis. They sync ok from gcal, but does fetch correctly after posting

t-suwa commented 6 years ago

It seems no UTF-8 encoding has done before posting json data, and this should be the reason of corrupted unicode characters.

See #108

telotortium commented 4 years ago

Hi everyone! This repository is obsolete - the actively developed fork is now https://github.com/kidd/org-gcal.el, which is also the "org-gcal.el" on MELPA (see #115). I'm one of the maintainers of https://github.com/kidd/org-gcal.el. I can't directly close issues or PRs on this repo, but please download https://github.com/kidd/org-gcal.el and see if your issue or PR is still applicable. If so, open an issue or PR on https://github.com/kidd/org-gcal.el. In any case, you should close your issue or PR in this repo.