UnicodeEncodeError: charmap codec can't encode character u'\u2013'

670 views
Skip to first unread message

sslater98

unread,
Nov 3, 2017, 6:03:38 AM11/3/17
to GAM for G Suite
User in our org is a member of 202 groups
When I try to get info on this user, gam 4.32 throws an error after listing a handful of them.

gam info user <username> 

Traceback (most recent call last):
  File "gam.py", line 12345, in <module>
  File "gam.py", line 11731, in ProcessGAMCommand
  File "gam.py", line 8816, in doGetUserInfo
  File "encodings\cp437.py", line 12, in encode
UnicodeEncodeError: 'charmap' codec can't encode character u'\u2013' in position 27: character maps to <undefined>
[7016] Failed to execute script gam

Running the command on a user with fewer groups succeeds.

Ross Scroggs

unread,
Nov 3, 2017, 7:30:03 AM11/3/17
to google-ap...@googlegroups.com
You have users with extended characters in the information but code page 437 (cp437) can't display them.
Do: chcp 1252
Try again.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/fc3346c7-9c2f-430d-9d34-961112012c4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sslater98

unread,
Nov 3, 2017, 9:44:34 AM11/3/17
to GAM for G Suite
I don't understand where I would make that change.


On Friday, November 3, 2017 at 7:30:03 AM UTC-4, Ross Scroggs wrote:
You have users with extended characters in the information but code page 437 (cp437) can't display them.
Do: chcp 1252
Try again.

On Nov 2, 2017, at 8:31 AM, sslater98 <ssla...@gmail.com> wrote:

User in our org is a member of 202 groups
When I try to get info on this user, gam 4.32 throws an error after listing a handful of them.

gam info user <username> 

Traceback (most recent call last):
  File "gam.py", line 12345, in <module>
  File "gam.py", line 11731, in ProcessGAMCommand
  File "gam.py", line 8816, in doGetUserInfo
  File "encodings\cp437.py", line 12, in encode
UnicodeEncodeError: 'charmap' codec can't encode character u'\u2013' in position 27: character maps to <undefined>
[7016] Failed to execute script gam

Running the command on a user with fewer groups succeeds.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

sslater98

unread,
Nov 3, 2017, 9:47:48 AM11/3/17
to GAM for G Suite
Ok, I took a guess and typed the following:

C:\gam-64>chcp 1252
Active code page: 1252

Still getting a similar error:
  File "encodings\cp1252.py", line 12, in encode
UnicodeEncodeError: 'charmap' codec can't encode character u'\u200b' in position 4: character maps to <undefined>
[11124] Failed to execute script gam

Ross Scroggs

unread,
Nov 3, 2017, 9:48:14 AM11/3/17
to google-ap...@googlegroups.com
In the Command Prompt or PowerShell window where yoiu ran the gam command.

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.

To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

Ross Scroggs

unread,
Nov 3, 2017, 9:52:52 AM11/3/17
to google-ap...@googlegroups.com
u'\u200b' is a ZeroWidth Spae character as described below which is probably not what you want in the data

http://www.fileformat.info/info/unicode/char/200B/index.htm

Does any output come out before the error?

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.

To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

sslater98

unread,
Nov 3, 2017, 9:57:28 AM11/3/17
to GAM for G Suite
Weirder still, if I redirect the output to a text file, I get all the groups and no errors at all, even with the 'default' codepage 437.  For me, this is an easy workaround.  Thanks for your help Ross.
Reply all
Reply to author
Forward
0 new messages