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

Python 3 automatically encodes strings as unicode, but Ctype deals with strings in ascii #81

Open
AdamKormos opened this issue Nov 19, 2022 · 1 comment

Comments

@AdamKormos
Copy link

Hey all, I just found this API today because I was requested to implement steam achievements for a game.
I automatized the achievement example sample code a bit, and had to debug for a long session, trying to figure out why setting stats and achievements (SetStat() and SetAchievement()) didn't go through.
I've looked up many websites and scrolled the official steamworks documentation quite a lot, until I found this post: https://lightrun.com/answers/philippj-steamworkspy-setstat-always-fails
This person also fought the same issue, and figured out the strings passed into the API's parameters need to be explicitly told to be encoded to ascii. After I put ".encode('ascii')" after every string parameter for getter/setter API functions, things started to work for me!
I'd advise adding the same encoding functions to string parameters before they're passed to the actual function, as such:

    def SetAchievement(self, name: str) -> bool:
        """Set a given achievement

        :param name: str
        :return: bool
        """
        return self.steam.SetAchievement(name.encoding('ascii'))
@philippj
Copy link
Owner

Hi, thanks for reporting this. I will check out the described behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants