HerrMagiic / CSS-CreateCustomCommands

The Custom Commands Plugin allows you to create and customize commands for your server. These commands can display messages, perform server-side actions, and more.
https://github.com/HerrMagiic/CSS-CreateCustomCommands/tree/main/Examples
MIT License
44 stars 1 forks source link

Support Unicode Characters #61

Open tungsten35 opened 4 months ago

tungsten35 commented 4 months ago

Hello, My plugin works fine but in logs there is something like this. I think it is because turkish language like "ç, ş, ğ, ı,". Can you fix if it is possible please?

2024-05-13 10:47:25.389 +03:00 [EROR] (cssharp:ConfigManager) Failed to parse configuration file for CustomCommands System.Text.Json.JsonException: The JSON value could not be converted to CustomCommands.CustomCommandsConfig. Path: $ | LineNumber: 0 | BytePositionInLine: 1. at System.Text.Json.ThrowHelper.ThrowJsonException_DeserializeUnableToConvertValue(Type propertyType) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue) at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan1 utf8Json, JsonTypeInfo1 jsonTypeInfo, Nullable1 actualByteCount) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan1 json, JsonTypeInfo1 jsonTypeInfo) at CounterStrikeSharp.API.Modules.Config.ConfigManager.Load[T](String pluginName) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Modules/Config/ConfigManager.cs:line 86

HerrMagiic commented 4 months ago

Hey, I'm currently not home, so I can't test it myself, but here's a suggestion that should work. You can indeed utilize special characters in your configuration file by representing them using Unicode escape sequences.

Here's a link to a list of Unicode characters for reference: List of Unicode characters

To integrate these characters into your configuration file, you'll need to use the \u<Code> format. For instance, let's take the character ğ, which has the Unicode code point U+011F. In your configuration file, you'd represent it like this:

[
  {
    "Title": "Test",
    "Description": "Test Command",
    "Command": "test",
    "Message": "blablabla \u011F blablabla"
  }
]

By using this approach, you'll be able to incorporate special characters seamlessly into your configuration without encountering any parsing issues.

image

Feel free to give it a try, and let me know if you encounter any further issues!

tungsten35 commented 4 months ago

It will be so hard to do this because there are a lot of turkish characters in my sentences. I set some jailbreak rules and it is long. I can wait updating your plugin. I hope you can fix it. Have a nice day.

HerrMagiic commented 4 months ago

Use this until i update the plugin. Paste you JSON with the turkish characters into the website and click on Beautify and copy the output into the json file.

https://www.beautifyjson.org/

tungsten35 commented 4 months ago

I will. Thank you so much for your help!