matthewprenger / CurseGradle

Gradle plugin to upload Minecraft mods to CurseForge
MIT License
1 stars 1 forks source link

Add emoji support to changelogs #9

Closed The-Fireplace closed 5 years ago

The-Fireplace commented 7 years ago

When uploading changelogs using CurseGradle, it replaces emojis with question marks. However, when I edit the description on CurseForge, it allows emojis to be used.

I tested this with 🐱👤

dshadowwolf commented 6 years ago

I was just looking to do this as a side-step from working on the few mods I've got some responsibility for and I cannot find where CurseGradle ever touches the text supplied for the CurseForge changelog, so I have a few questions to ask here: 1) Are you using plain text with the emoji inserted as unicode characters (like "U+1F4A9 - Pile of Poo" -- 💩) or are you using the :<emoji>: markdown ? (such as 💩 ?) 2) If you are using Markdown as the type for the changelog, did you set the "changelogType" setting to "markdown" ?

As I said - I can't find where CurseGradle does more than load the file for sending it to CurseForge using the API. Hence asking for input to try and figure out what might be going wrong.

The-Fireplace commented 6 years ago

I am using the Unicode characters, typed from the Windows 10 on-screen keyboard.

dshadowwolf commented 6 years ago

Ah, that might be the issue - the default encoding for Windows is UTF-16 and the default for JSON is UTF-8 (and the default character set used in file loading by the gradle 'file()' object is UTF-8 as well). Let me take a look at some generated results and see if the issue is that you're (accidentally) including a UTF-16 character in what is supposed to be a UTF-8 file...

dshadowwolf commented 6 years ago

Testing in raw Groovy shows there is, apparently, an issue with java.io.File - looks like I'll have to go dig up Gradle's file class to see if it persists there, but... I'm seeing that the data is actually loaded correctly (U+1F4A9 comes out of the UTF-16LE encoded file as 0xd83d 0xdca9 and out of the UTF-8 encoded one as 0xf0 0x9f 0x92 0xa9 - which is correct), but File.text returns a series of ? for the extended characters (in both cases) and it holds true even for File.getText() with the correct encoding given. More investigation is needed, as this is looking like, possibly, an issue with Groovy and not Gradle or CurseGradle.

dshadowwolf commented 6 years ago

Thanks to the genius of Paul Fulham a work-around/solution has been, hopefully, found. It seems that the file handling details of Groovy are kind of twisted. File.getText() is supposed to return a string, but it doesn't seem to initialize properly if the input is non-ASCII. If you change your "changelog = " line from just using "file()" to using: new String(file(...).getText('UTF-8').getBytes('UTF-8')) makes things work.

dshadowwolf commented 6 years ago

Side Note: I am working on fixing this inside CurseGradle, its just that I'm getting rather annoyed by the docs saying one thing but the code doing something completely different when it comes to Gradle.