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

Fix text encoder/decoder of CtdEditor. #1133

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

kenjiuno
Copy link
Collaborator

Added encoding selector.

2024-12-30_03h40_48

Implement Japanese encoder/decoder.

2024-12-29_21h53_59

The international encoder/decoder will work even if used for Japanese data.

2024-12-29_21h54_07

Remove JapaneseCtdEncoder which is not implemented yet.

Rename InternationalCtdEncoder into UnifiedCtdEncoder.

The refined decoder interface:

    public interface ICtdMessageDecode
    {
        string ToText(byte[] data, CtdToTextOptions opts = null);
    }
    public class CtdToTextOptions
    {
        /// <summary>
        /// Allow to decode unknown as `{:unk FF}` alternative instead of throwing an exception.
        /// </summary>
        public bool AllowUnkUsage { get; set; } = true;

        /// <summary>
        /// Decode input as Shift_JIS encoding.
        /// </summary>
        public bool DecodeAsShiftJIS { get; set; }
    }

The refined encoder interface:

    public interface ICtdMessageEncode
    {
        byte[] FromText(string text, CtdFromTextOptions opts = null);
    }
    public class CtdFromTextOptions
    {
        /// <summary>
        /// Encode input as Shift_JIS encoding.
        /// </summary>
        public bool EncodeAsShiftJIS { get; set; }
    }

Apply DI partially.

@shananas shananas merged commit 8f87027 into OpenKH:master Dec 30, 2024
3 checks passed
@kenjiuno kenjiuno deleted the fix-ctd-editor-1 branch December 30, 2024 05:24
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

Successfully merging this pull request may close these issues.

2 participants