65 Commits
v1.0 ... master

Author SHA1 Message Date
92ea31c29e Up to version 1.9.2. 2021-11-09 18:52:44 +00:00
3fbe10d460 General refactor. 2021-11-09 18:51:47 +00:00
889a8a84e5 Move to global using. 2021-11-09 18:50:43 +00:00
58f08d4cd3 Move to file-scoped namespaces. 2021-11-09 18:46:53 +00:00
2eb8a7add6 Update to .NET 6. 2021-11-09 18:45:35 +00:00
d92a6ec4a3 Fix naming of classes. 2021-04-30 16:07:46 +01:00
22a7ff28f5 Create debug symbols package. 2021-04-30 12:18:50 +01:00
5d6f925ad8 Bump version to 1.9. 2021-04-30 12:18:11 +01:00
b2dacda32e Update XML comments. 2021-04-30 12:18:11 +01:00
0a2bd101cb Use switch pattern matching. 2021-04-30 12:18:11 +01:00
0fcde80b5e Update Macintosh codepages to include the GUI symbols. 2021-04-30 12:18:11 +01:00
8df142e1b8 Update ZX81 to include Unicode 13.0 symbols. 2021-04-30 12:18:11 +01:00
b92b7e8740 Update ZX80 to include Unicode 13.0 symbols. 2021-04-30 12:18:11 +01:00
e7f8f44043 Update PETSCII to include Unicode 13.0 symbols. 2021-04-30 12:18:10 +01:00
91fe457af7 Update GEM to include Unicode 13.0 symbols. 2021-04-30 12:18:10 +01:00
3b690c8357 Update ATASCII to include Unicode 13.0 symbols. 2021-04-30 12:18:10 +01:00
6676144053 Update Apple //gs to include Unicode 13.0 symbols. 2021-04-30 12:18:10 +01:00
23fdff225d Update Apple IIc to include Unicode 13.0 symbols. 2021-04-30 12:18:10 +01:00
a390eb1c5a Implement Atari ST characters added in Unicode 13.0. 2021-04-30 12:18:09 +01:00
32425c908c Implement Atari ST characters added in Unicode 13.0. 2021-04-29 19:42:46 +01:00
c3304d356d Add class to do conversions using Runes, for codepages that contain characters needing UTF-16 surrogates. 2021-04-29 19:37:15 +01:00
01df1f48e1 Use abstract class to implement encoding methods. 2021-04-29 18:42:12 +01:00
852dd674a3 Code refactor and cleanup. 2021-04-29 15:36:47 +01:00
99767331e0 Update unit tests for .NET Core. 2021-04-29 15:24:03 +01:00
edfa3efaa3 Migrate to .NET Core 3.1 and .NET 5.0 2021-04-29 15:22:14 +01:00
187aca10d9 Add EditorConfig file. 2021-04-29 15:22:00 +01:00
7cc7c1fce7 Add JetBrains project files. 2021-04-29 15:21:47 +01:00
3a2e7005e2 Update gitignore. 2021-04-29 15:21:35 +01:00
64c98fd2f3 Update copyright year 2021-04-29 15:19:26 +01:00
3e34e567c4 Up version to 1.7. 2019-04-23 23:39:07 +01:00
2465b149ef Update versions and downgrade minimum .NET Framework version to 4.0. 2019-04-23 23:33:33 +01:00
60596ec513 General reformat. 2019-04-23 23:20:55 +01:00
33e889ed02 Update copyright date. 2019-04-23 23:12:01 +01:00
a295d6a9de Use correct inheritance keywords. 2019-04-23 23:10:31 +01:00
663bb8c4c4 Add support for .NET Core and .NET Standard. 2019-04-23 23:01:03 +01:00
01dceea917 Update dependencies. 2019-04-23 22:43:50 +01:00
bd24b9be74 Add missing files to git. 2019-04-23 22:42:26 +01:00
21a0aa6349 Up to version 1.6.1. 2018-03-11 15:23:43 +00:00
33d27e098f Add support for GEOS character set. 2018-03-07 18:58:31 +00:00
967687dfd1 General refactor. 2018-03-07 18:56:12 +00:00
e9f4aae440 Add support for GEM character set. 2018-03-01 03:04:08 +00:00
4cdbe9dda9 Add suport for Radix-50, fixes #3 2017-12-27 21:36:57 +00:00
f7a073cd27 Updated copyright strings. 2017-12-26 19:17:19 +00:00
88ee61203c Refactor and code cleanup. 2017-12-26 18:45:47 +00:00
d292daec2b Added Apple II, IIc, IIe and IIgs character sets. 2017-12-26 18:27:38 +00:00
74b593aff1 Typo correction in XML documentation. 2017-12-26 18:03:09 +00:00
ad90cf06e2 Added MacRomanian. 2017-10-19 01:12:06 +01:00
788615826b Added MacRoman. 2017-10-19 01:05:56 +01:00
68d8af6750 Added MacUkrainian. 2017-10-19 00:53:14 +01:00
159bfb697d Added MacCyrillic. 2017-10-19 00:46:09 +01:00
4a0faa5b62 Added MacCentralEuropean. 2017-10-19 00:31:01 +01:00
802c106d82 Added MacCroatian. 2017-10-18 21:46:57 +01:00
5a83382bcd Added MacGreek. 2017-10-18 21:09:05 +01:00
15e9b9b432 Added MacTurkish. 2017-10-18 20:48:37 +01:00
d17336f244 Added support for MacHebrew. 2017-10-18 19:23:24 +01:00
e3886723a3 Added support for MacFarsi. 2017-10-18 19:04:08 +01:00
48bff1514e Added MacArabic. 2017-10-18 18:41:01 +01:00
e3b6c08008 Up version to 1.2.0. 2017-10-12 22:57:06 +01:00
19698c7191 Added GetEncoding() override. 2017-10-12 22:55:50 +01:00
5832c3c487 Name normalization. 2017-10-12 22:47:37 +01:00
f5e340412b Up version to 1.1.0. 2017-10-12 21:18:01 +01:00
74ec94cd4c Up version to 1.1.0. 2017-10-12 21:17:02 +01:00
b5867d9212 Updated packages. 2017-10-12 21:16:04 +01:00
1bef17c7a0 Added code to get a list of available encodings. 2017-10-12 21:11:04 +01:00
d873345124 Downgrade to .NET 4.0. 2017-06-06 18:29:29 +01:00
53 changed files with 11933 additions and 6159 deletions

633
.editorconfig Normal file
View File

@@ -0,0 +1,633 @@
root = true
[*]
charset=utf-8
next_line=crlf
insert_final_newline=false
indent_style=space
indent_size=4
# Generic non-language specific ones for Resharper and friends
brace_style=next_line
int_align=true
keep_existing_arrangement=false
place_simple_blocks_on_single_line=true
place_simple_declaration_blocks_on_single_line=true
place_attribute_on_same_line=false
space_after_unary_operator=false
space_after_comma=true
space_around_ternary_operator=true
space_around_binary_operator=true
space_around_member_access_operator=false
space_before_open_square_brackets=false
space_after_keywords_in_control_flow_statements=true
space_before_comma=false
space_between_method_call_name_and_opening_parenthesis=false
space_between_method_declaration_name_and_open_parenthesis=false
space_between_square_brackets=false
space_between_parentheses_of_control_flow_statements=false
accessor_owner_declaration_braces=next_line
accessor_declaration_braces=next_line
case_block_braces=next_line
initializer_braces=next_line
other_braces=next_line
allow_comment_after_lbrace=false
empty_block_style=together_same_line
braces_for_ifelse=not_required
braces_for_for=not_required
braces_for_foreach=not_required
braces_for_while=not_required
braces_for_dowhile=not_required
braces_for_using=not_required
braces_for_lock=not_required
braces_for_fixed=not_required
method_or_operator_body=expression_body
local_function_body=expression_body
constructor_or_destructor_body=expression_body
accessor_owner_body=expression_body
force_attribute_style=join
function_braces=next_line
force_control_statements_braces=always_remove
space_in_singleline_accessorholder=true
type_declaration_braces=next_line
invocable_declaration_braces=next_line
anonymous_method_declaration_braces=next_line
space_between_accessors_in_singleline_property=true
indent_nested_usings_stmt=true
space_within_empty_braces=false
indent_nested_fixed_stmt=true
indent_nested_lock_stmt=true
indent_nested_for_stmt=true
indent_nested_foreach_stmt=true
indent_nested_while_stmt=true
use_continuous_indent_inside_parens=true
indent_method_decl_pars=inside
indent_invocation_pars=inside
indent_statement_pars=inside
indent_typeparam_angles=inside
indent_typearg_angles=inside
indent_pars=inside
indent_preprocessor_if=outdent
indent_preprocessor_region=usual_indent
indent_preprocessor_other=usual_indent
indent_switch_labels=true
indent_type_constraints=true
stick_comment=false
alignment_tab_fill_style=use_spaces
align_multiline_parameter=true
align_multiline_extends_list=true
align_linq_query=true
align_multiline_binary_expressions_chain=true
outdent_binary_ops=true
align_multiline_calls_chain=true
outdent_dots=true
align_multiline_array_and_object_initializer=false
indent_anonymous_method_block=false
align_first_arg_by_paren=true
align_multiline_argument=true
align_tuple_components=true
align_multiline_expression=true
align_multiline_for_stmt=true
align_multiple_declaration=true
align_multline_type_parameter_list=true
align_multline_type_parameter_constrains=true
int_align_fields=true
int_align_properties=true
int_align_methods=true
int_align_parameters=false
int_align_variables=true
int_align_assignments=true
int_align_nested_ternary=true
int_align_invocations=false
int_align_binary_expressions=true
int_align_comments=true
int_align_switch_sections=true
keep_user_linebreaks=false
keep_existing_arrangement=false
keep_existing_linebreaks=false
max_line_length=120
wrap_before_comma=false
special_else_if_treatment=true
place_type_attribute_on_same_line=never
place_method_attribute_on_same_line=never
place_accessorholder_attribute_on_same_line=never
place_attribute_on_same_line=never
place_accessor_attribute_on_same_line=never
place_attribute_on_same_line=never
place_field_attribute_on_same_line=never
place_attribute_on_same_line=never
wrap_parameters_style=wrap_if_long
keep_existing_declaration_parens_arrangement=false
wrap_before_declaration_lpar=false
wrap_after_declaration_lpar=false
wrap_before_declaration_rpar=false
place_constructor_initializer_on_same_line=true
keep_existing_expr_member_arrangement=false
place_expr_method_on_single_line=true
place_expr_property_on_single_line=true
place_expr_accessor_on_single_line=true
wrap_before_arrow_with_expressions=false
place_type_constraints_on_same_line=true
wrap_before_first_type_parameter_constraint=true
wrap_multiple_type_parameter_constraints_style=wrap_if_long
wrap_before_type_parameter_langle=true
wrap_before_extends_colon=false
wrap_extends_list_style=wrap_if_long
keep_existing_declaration_block_arrangement=false
place_abstract_accessorholder_on_single_line=true
place_simple_accessorholder_on_single_line=false
place_accessor_with_attrs_holder_on_single_line=false
place_simple_accessor_on_single_line=true
place_simple_method_on_single_line=false
keep_existing_enum_arrangement=false
place_simple_enum_on_single_line=false
wrap_enum_declaration=wrap_if_long
new_line_before_else=true
new_line_before_while=false
wrap_for_stmt_header_style=wrap_if_long
wrap_multiple_declaration_style=wrap_if_long
keep_existing_embedded_arrangement=false
place_simple_embedded_statement_on_same_line=false
place_simple_case_statement_on_same_line=true
keep_existing_embedded_block_arrangement=false
place_simple_embedded_block_on_same_line=false
place_simple_anonymousmethod_on_single_line=false
keep_existing_initializer_arrangement=false
place_simple_initializer_on_single_line=false
wrap_object_and_collection_initializer_style=chop_always
wrap_array_initializer_style=wrap_if_long
wrap_arguments_style=wrap_if_long
keep_existing_invocation_parens_arrangement=false
wrap_after_invocation_lpar=false
wrap_before_invocation_rpar=false
wrap_after_dot_in_method_calls=true
wrap_chained_method_calls=wrap_if_long
wrap_before_binary_opsign=false
wrap_chained_binary_expressions=wrap_if_long
force_chop_compound_if_expression=true
force_chop_compound_while_expression=true
force_chop_compound_do_expression=true
wrap_before_ternary_opsigns=true
wrap_ternary_expr_style=wrap_if_long
nested_ternary_style=expanded
wrap_linq_expressions=wrap_if_long
wrap_before_linq_expression=false
place_linq_into_on_new_line=false
wrap_verbatim_interpolated_strings=wrap_if_long
extra_spaces=remove_all
space_after_keywords_in_control_flow_statements=false
space_between_method_call_name_and_opening_parenthesis=false
space_between_method_declaration_name_and_open_parenthesis=false
space_before_typeof_parentheses=false
space_before_checked_parentheses=false
space_before_sizeof_parentheses=false
space_before_nameof_parentheses=false
space_between_keyword_and_expression=true
space_between_keyword_and_type=true
space_around_assignment_op=true
space_around_logical_op=true
space_around_binary_operator=true
space_around_equality_op=true
space_around_relational_op=true
space_around_bitwise_op=true
space_around_additive_op=true
space_around_multiplicative_op=true
space_around_shift_op=true
space_around_nullcoalescing_op=true
space_around_arrow_op=false
space_after_logical_not_op=false
space_after_unary_operator=false
space_after_cast=false
space_around_dot=false
space_around_lambda_arrow=true
space_before_pointer_asterik_declaration=false
space_before_nullable_mark=false
blank_lines_around_class_definition=1
namespace_indentation=all
space_within_template_argument=false
align_union_type_usage=true
space_in_singleline_method=true
space_in_singleline_anonymous_method=true
space_within_single_line_array_initializer_braces=true
space_around_arrow_op=false
# These are for markup languages (HTML, XML, etc)
spaces_around_eq_in_pi_attribute=false
space_after_last_pi_attribute=true
pi_attributes_indent=align_by_first_attribute
blank_line_after_pi=true
spaces_around_eq_in_attribute=false
space_after_last_attribute=false
space_before_self_closing=true
attribute_style=on_single_line
attribute_indent=align_by_first_attribute
sort_attributes=true
sort_class_selectors=true
max_blank_lines_between_tags=0
linebreak_before_all_elements=true
linebreak_before_multiline_elements=true
quote_style=doublequoted
delete_quotes_from_solid_values=false
normalize_tag_names=true
[{.babelrc,.stylelintrc,jest.config,.eslintrc,.prettierrc,*.json,*.jsb3,*.jsb2,*.bowerrc}]
indent_size=2
[*.js.map]
indent_size=2
[*.{css,scss}]
indent_size=2
declarations_style=separate_lines_for_nonsingle
media_query_style=separate_lines
selector_style=same_line
properties_style=separate_lines_for_nonsingle
brace_style=next_line
[{.analysis_options,*.yml,*.yaml}]
indent_size=2
# Xml project files
[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
indent_size = 2
# Xml files
[*.{xml,stylecop,resx,ruleset}]
indent_size = 2
# Xml config files
[*.{props,targets,config,nuspec}]
indent_size = 2
# .net files
[*.{cs,vb}]
# These set the this. / Me.
dotnet_style_qualification_for_field=false:warning
dotnet_style_qualification_for_property=false:warning
dotnet_style_qualification_for_method=false:warning
dotnet_style_qualification_for_event=false:warning
# These make it suggest Int32 instead of int, etc.
dotnet_style_predefined_type_for_locals_parameters_members=true:suggestion
dotnet_style_predefined_type_for_member_access=true:suggestion
# This controls implicit access modifiers
dotnet_style_require_accessibility_modifiers=never:suggestion
# Prefer non modified fields to be marked readonly
dotnet_style_readonly_field=true:warning
# Parenthesis settings
dotnet_style_parentheses_in_arithmetic_binary_operators=always_for_clarity:warning
dotnet_style_parentheses_in_relational_binary_operators=always_for_clarity:warning
dotnet_style_parentheses_in_other_binary_operators=always_for_clarity:warning
dotnet_style_parentheses_in_other_operators=always_for_clarity:warning
dotnet_style_object_initializer=true:suggestion
dotnet_style_collection_initializer=true:suggestion
dotnet_style_explicit_tuple_names=true:error
dotnet_style_prefer_inferred_tuple_names=true:warning
dotnet_style_prefer_inferred_anonymous_type_member_names=true:warning
dotnet_style_prefer_is_null_check_over_reference_equality_method=true:warning
dotnet_style_prefer_conditional_expression_over_return=true:warning
dotnet_style_coalesce_expression=true:warning
dotnet_style_null_propagation=true:error
dotnet_sort_system_directives_first=true
# Constants in C style, all-caps
dotnet_naming_rule.constant_fields_caps.symbols = constant_fields
dotnet_naming_rule.constant_fields_caps.severity = warning
dotnet_naming_rule.constant_fields_caps.style = caps_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.required_modifiers = const
dotnet_naming_style.caps_style.capitalization = all_upper
# interfaces should be prefixed with I
dotnet_naming_rule.pascal_case_for_interface.severity = error
dotnet_naming_rule.pascal_case_for_interface.symbols = interfaces_fields
dotnet_naming_rule.pascal_case_for_interface.style = pascal_case_interface_style
dotnet_naming_symbols.interfaces_fields.applicable_kinds = interface
dotnet_naming_style.pascal_case_interface_style.required_prefix = I
dotnet_naming_style.pascal_case_interface_style.capitalization = pascal_case
## internal and private fields should be _camelCase
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = warning
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
# 2018-12-07 NP: This is not yet working in VS2017
# local variables should be camelCase
#dotnet_naming_rule.camel_case_for_locals.severity = suggestion
#dotnet_naming_rule.camel_case_for_locals.symbols = local_fields
#dotnet_naming_rule.camel_case_for_locals.style = camel_case_style
#dotnet_naming_symbols.local_fields.applicable_kinds = local
#dotnet_naming_style.camel_case_style.capitalization = camel_case
[*.cs]
# var var var
csharp_style_var_for_built_in_types=false:warning
csharp_style_var_when_type_is_apparent=true:suggestion
csharp_style_var_elsewhere=false:warning
csharp_style_expression_bodied_methods=when_on_single_line:suggestion
csharp_style_expression_bodied_constructors=when_on_single_line:suggestion
csharp_style_expression_bodied_operators=when_on_single_line:suggestion
csharp_style_expression_bodied_properties=when_on_single_line:suggestion
csharp_style_expression_bodied_indexers=when_on_single_line:suggestion
csharp_style_expression_bodied_accessors=when_on_single_line:suggestion
csharp_style_pattern_matching_over_is_with_cast_check=true:warning
csharp_style_pattern_matching_over_as_with_null_check=when_on_single_line:warning
csharp_style_inlined_variable_declaration=true:warning
csharp_prefer_simple_default_expression=true:warning
csharp_style_deconstructed_variable_declaration=false:warning
csharp_style_throw_expression=true:warning
csharp_style_conditional_delegate_call=true:warning
csharp_prefer_braces=false
csharp_new_line_before_open_brace=all
csharp_new_line_before_else=true
csharp_new_line_before_catch=true
csharp_new_line_before_finally=true
csharp_new_line_before_members_in_object_initializers=true
csharp_new_line_before_members_in_anonymous_types=true
csharp_new_line_between_query_expression_clauses=true
csharp_indent_case_contents=true
csharp_indent_switch_labels=true
csharp_indent_labels=flush_left
csharp_space_after_cast=false
csharp_space_after_keywords_in_control_flow_statements=false
csharp_space_between_method_declaration_parameter_list_parentheses=false
csharp_space_between_parentheses=none
csharp_space_before_colon_in_inheritance_clause=true
csharp_space_after_colon_in_inheritance_clause=true
csharp_space_around_binary_operators=before_and_after
csharp_space_between_method_declaration_empty_parameter_list_parentheses=false
csharp_space_between_method_call_name_and_opening_parenthesis=false
csharp_space_between_method_call_empty_parameter_list_parentheses=false
csharp_preserve_single_line_statements=false
csharp_preserve_single_line_blocks=true
csharp_blank_lines_around_region=0
csharp_blank_lines_inside_region=0
csharp_blank_lines_before_single_line_comment=1
csharp_keep_blank_lines_in_declarations=1
csharp_remove_blank_lines_near_braces_in_declarations=true
csharp_blank_lines_after_start_comment=false
csharp_blank_lines_between_using_groups=0
csharp_blank_lines_after_using_list=1
csharp_blank_lines_around_namespace=1
csharp_blank_lines_inside_namespace=0
csharp_blank_lines_around_type=1
csharp_blank_lines_inside_type=0
csharp_blank_lines_around_field=0
csharp_blank_lines_around_single_line_field=0
csharp_blank_lines_around_property=1
csharp_blank_lines_around_single_line_property=0
csharp_blank_lines_around_auto_property=0
csharp_blank_lines_around_single_line_auto_property=0
csharp_blank_lines_around_invocable=1
csharp_blank_lines_around_single_line_invocable=1
csharp_keep_blank_lines_in_code=1
csharp_remove_blank_lines_near_braces_in_code=true
csharp_blank_lines_around_local_method=1
csharp_blank_lines_around_single_line_local_method=1
csharp_blank_lines_before_control_transfer_statements=1
csharp_blank_lines_after_control_transfer_statements=1
csharp_blank_lines_before_block_statements=1
csharp_blank_lines_after_block_statements=1
csharp_blank_lines_before_multiline_statements=1
csharp_blank_lines_after_multiline_statements=1
csharp_type_declaration_braces=next_line
csharp_brace_style=next_line
csharp_indent_inside_namespace=true
csharp_invocable_declaration_braces=next_line
csharp_anonymous_method_declaration_braces=next_line
csharp_accessor_owner_declaration_braces=next_line
csharp_accessor_declaration_braces=next_line
csharp_case_block_braces=next_line
csharp_initializer_braces=next_line
csharp_other_braces=next_line
csharp_allow_comment_after_lbrace=false
csharp_empty_block_style=together_same_line
csharp_for_built_in_types=use_explicit_type
csharp_for_simple_types=use_var_when_evident
csharp_for_other_types=use_explicit_type
csharp_prefer_separate_deconstructed_variables_declaration=true
csharp_prefer_explicit_discard_declaration=false
csharp_instance_members_qualify_members=none
csharp_builtin_type_reference_style=use_keyword
csharp_prefer_qualified_reference=false
csharp_add_imports_to_deepest_scope=false
csharp_allow_alias=true
csharp_default_private_modifier=implicit
csharp_default_internal_modifier=explicit
csharp_arguments_literal=positional
csharp_arguments_string_literal=positional
csharp_arguments_named=positional
csharp_arguments_anonymous_function=positional
csharp_arguments_other=positional
csharp_braces_for_ifelse=not_required
csharp_braces_for_for=not_required
csharp_braces_for_foreach=not_required
csharp_braces_for_while=not_required
csharp_braces_for_dowhile=not_required
csharp_braces_for_using=not_required
csharp_braces_for_lock=not_required
csharp_braces_for_fixed=not_required
csharp_method_or_operator_body=expression_body
csharp_local_function_body=expression_body
csharp_constructor_or_destructor_body=expression_body
csharp_accessor_owner_body=expression_body
csharp_force_attribute_style=join
csharp_indent_nested_usings_stmt=true
csharp_builtin_type_reference_for_member_access_style=use_keyword
csharp_indent_nested_fixed_stmt=true
csharp_indent_nested_lock_stmt=true
csharp_indent_nested_for_stmt=true
csharp_indent_nested_foreach_stmt=true
csharp_indent_nested_while_stmt=true
csharp_use_continuous_indent_inside_parens=true
csharp_indent_method_decl_pars=inside
csharp_indent_invocation_pars=inside
csharp_indent_statement_pars=inside
csharp_indent_typeparam_angles=inside
csharp_indent_typearg_angles=inside
csharp_indent_pars=inside
csharp_indent_preprocessor_if=outdent
csharp_indent_preprocessor_region=usual_indent
csharp_indent_preprocessor_other=usual_indent
csharp_indent_switch_labels=true
csharp_indent_type_constraints=true
csharp_stick_comment=false
csharp_alignment_tab_fill_style=use_spaces
csharp_align_multiline_parameter=true
csharp_align_multiline_extends_list=true
csharp_align_linq_query=true
csharp_align_multiline_binary_expressions_chain=true
csharp_outdent_binary_ops=true
csharp_align_multiline_calls_chain=true
csharp_outdent_dots=true
csharp_align_multiline_array_and_object_initializer=false
csharp_indent_anonymous_method_block=false
csharp_align_first_arg_by_paren=true
csharp_align_multiline_argument=true
csharp_align_tuple_components=true
csharp_align_multiline_expression=true
csharp_align_multiline_for_stmt=true
csharp_align_multiple_declaration=true
csharp_align_multline_type_parameter_list=true
csharp_align_multline_type_parameter_constrains=true
csharp_int_align_fields=true
csharp_int_align_properties=true
csharp_int_align_methods=true
csharp_int_align_parameters=false
csharp_int_align_variables=true
csharp_int_align_assignments=true
csharp_int_align_nested_ternary=true
csharp_int_align_invocations=false
csharp_int_align_binary_expressions=true
csharp_int_align_comments=true
csharp_int_align_switch_sections=true
csharp_int_align=true
csharp_keep_user_linebreaks=false
csharp_keep_existing_arrangement=false
csharp_keep_existing_linebreaks=false
csharp_max_line_length=120
csharp_wrap_before_comma=false
csharp_special_else_if_treatment=true
csharp_insert_final_newline=false
csharp_place_type_attribute_on_same_line=never
csharp_place_method_attribute_on_same_line=never
csharp_place_accessorholder_attribute_on_same_line=never
csharp_place_attribute_on_same_line=never
csharp_place_accessor_attribute_on_same_line=never
csharp_place_attribute_on_same_line=never
csharp_place_field_attribute_on_same_line=never
csharp_place_attribute_on_same_line=never
csharp_wrap_parameters_style=wrap_if_long
csharp_keep_existing_declaration_parens_arrangement=false
csharp_wrap_before_declaration_lpar=false
csharp_wrap_after_declaration_lpar=false
csharp_wrap_before_declaration_rpar=false
csharp_place_constructor_initializer_on_same_line=true
csharp_keep_existing_expr_member_arrangement=false
csharp_place_expr_method_on_single_line=true
csharp_place_expr_property_on_single_line=true
csharp_place_expr_accessor_on_single_line=true
csharp_wrap_before_arrow_with_expressions=false
csharp_place_type_constraints_on_same_line=true
csharp_wrap_before_first_type_parameter_constraint=true
csharp_wrap_multiple_type_parameter_constraints_style=wrap_if_long
csharp_wrap_before_type_parameter_langle=true
csharp_wrap_before_extends_colon=false
csharp_wrap_extends_list_style=wrap_if_long
csharp_keep_existing_declaration_block_arrangement=false
csharp_place_abstract_accessorholder_on_single_line=true
csharp_place_simple_accessorholder_on_single_line=false
csharp_place_accessor_with_attrs_holder_on_single_line=false
csharp_place_simple_accessor_on_single_line=true
csharp_place_simple_method_on_single_line=false
csharp_keep_existing_enum_arrangement=false
csharp_place_simple_enum_on_single_line=false
csharp_wrap_enum_declaration=wrap_if_long
csharp_new_line_before_else=true
csharp_new_line_before_while=false
csharp_wrap_for_stmt_header_style=wrap_if_long
csharp_wrap_multiple_declaration_style=wrap_if_long
csharp_keep_existing_embedded_arrangement=false
csharp_place_simple_embedded_statement_on_same_line=false
csharp_place_simple_case_statement_on_same_line=true
csharp_keep_existing_embedded_block_arrangement=false
csharp_place_simple_embedded_block_on_same_line=false
csharp_place_simple_anonymousmethod_on_single_line=false
csharp_keep_existing_initializer_arrangement=false
csharp_place_simple_initializer_on_single_line=false
csharp_wrap_object_and_collection_initializer_style=chop_always
csharp_wrap_array_initializer_style=wrap_if_long
csharp_wrap_arguments_style=wrap_if_long
csharp_keep_existing_invocation_parens_arrangement=false
csharp_wrap_after_invocation_lpar=false
csharp_wrap_before_invocation_rpar=false
csharp_wrap_after_dot_in_method_calls=true
csharp_wrap_chained_method_calls=wrap_if_long
csharp_wrap_before_binary_opsign=false
csharp_wrap_chained_binary_expressions=wrap_if_long
csharp_force_chop_compound_if_expression=true
csharp_force_chop_compound_while_expression=true
csharp_force_chop_compound_do_expression=true
csharp_wrap_before_ternary_opsigns=true
csharp_wrap_ternary_expr_style=wrap_if_long
csharp_nested_ternary_style=expanded
csharp_wrap_linq_expressions=wrap_if_long
csharp_wrap_before_linq_expression=false
csharp_place_linq_into_on_new_line=false
csharp_wrap_verbatim_interpolated_strings=wrap_if_long
csharp_extra_spaces=remove_all
csharp_space_after_keywords_in_control_flow_statements=false
csharp_space_between_method_call_name_and_opening_parenthesis=false
csharp_space_between_method_declaration_name_and_open_parenthesis=false
csharp_space_before_typeof_parentheses=false
csharp_space_before_checked_parentheses=false
csharp_space_before_sizeof_parentheses=false
csharp_space_before_nameof_parentheses=false
csharp_space_between_keyword_and_expression=true
csharp_space_between_keyword_and_type=true
csharp_space_around_assignment_op=true
csharp_space_around_logical_op=true
csharp_space_around_binary_operator=true
csharp_space_around_equality_op=true
csharp_space_around_relational_op=true
csharp_space_around_bitwise_op=true
csharp_space_around_additive_op=true
csharp_space_around_multiplicative_op=true
csharp_space_around_shift_op=true
csharp_space_around_nullcoalescing_op=true
csharp_space_around_arrow_op=false
csharp_space_after_logical_not_op=false
csharp_space_after_unary_operator=false
csharp_space_after_cast=false
csharp_space_around_dot=false
csharp_space_around_lambda_arrow=true
csharp_space_before_pointer_asterik_declaration=false
csharp_space_before_nullable_mark=false
csharp_style_namespace_declarations = file_scoped:warning
[*.cshtml]
linebreaks_around_razor_statements=true
blank_lines_around_razor_functions=true
blank_lines_around_razor_helpers=true
blank_lines_around_razor_sections=true
# C++
[*.{cc,cpp,cxx,h,hpp,hxx}]
cpp_indent_access_specifiers_from_class=true
cpp_indent_wrapped_function_names=false
cpp_align_multiline_type_argument=true
# C, C++ and ObjectiveC
[*.{c,h,cc,cpp,cxx,m,hpp,hxx}]
indent_preprocessor_directives=normal
indent_type_constraints=true
# Javascript and Typescript
[*.{js,js.map,ts}]
quote_style=doublequoted
termination_style=ensure_semicolon

508
.gitignore vendored
View File

@@ -38,3 +38,511 @@ Thumbs.db
#dotCover
*.dotCover
### macOS template
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Windows template
# Windows thumbnail cache files
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
### Linux template
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### VisualStudioCode template
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
### VisualStudio template
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View File

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MarkdownProjectSettings" wasCopied="false">
<PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="NONE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="false" showSelectionInPreview="true" openRemoteLinks="true" replaceUnicodeEmoji="false" lastLayoutSetsDefault="false">
<PanelProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
</PanelProvider>
</PreviewSettings>
<ParserSettings gitHubSyntaxChange="false" emojiShortcuts="1" emojiImages="0">
<PegdownExtensions>
<option name="ABBREVIATIONS" value="false" />
<option name="ANCHORLINKS" value="true" />
<option name="ASIDE" value="false" />
<option name="ATXHEADERSPACE" value="true" />
<option name="AUTOLINKS" value="false" />
<option name="DEFINITIONS" value="false" />
<option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
<option name="FENCED_CODE_BLOCKS" value="true" />
<option name="FOOTNOTES" value="false" />
<option name="HARDWRAPS" value="false" />
<option name="HTML_DEEP_PARSER" value="false" />
<option name="INSERTED" value="false" />
<option name="QUOTES" value="false" />
<option name="RELAXEDHRULES" value="true" />
<option name="SMARTS" value="false" />
<option name="STRIKETHROUGH" value="true" />
<option name="SUBSCRIPT" value="false" />
<option name="SUPERSCRIPT" value="false" />
<option name="SUPPRESS_HTML_BLOCKS" value="false" />
<option name="SUPPRESS_INLINE_HTML" value="false" />
<option name="TABLES" value="true" />
<option name="TASKLISTITEMS" value="true" />
<option name="TOC" value="false" />
<option name="WIKILINKS" value="false" />
</PegdownExtensions>
<ParserOptions>
<option name="ADMONITION_EXT" value="false" />
<option name="ATTRIBUTES_EXT" value="false" />
<option name="COMMONMARK_LISTS" value="true" />
<option name="DUMMY" value="false" />
<option name="EMOJI_SHORTCUTS" value="true" />
<option name="ENUMERATED_REFERENCES_EXT" value="false" />
<option name="FLEXMARK_FRONT_MATTER" value="false" />
<option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="false" />
<option name="GFM_TABLE_RENDERING" value="true" />
<option name="GITBOOK_URL_ENCODING" value="false" />
<option name="GITHUB_LISTS" value="false" />
<option name="GITHUB_WIKI_LINKS" value="false" />
<option name="GITLAB_EXT" value="false" />
<option name="GITLAB_MATH_EXT" value="false" />
<option name="GITLAB_MERMAID_EXT" value="false" />
<option name="HEADER_ID_NON_ASCII_TO_LOWERCASE" value="false" />
<option name="HEADER_ID_NO_DUPED_DASHES" value="false" />
<option name="JEKYLL_FRONT_MATTER" value="false" />
<option name="MACROS_EXT" value="false" />
<option name="NO_TEXT_ATTRIBUTES" value="false" />
<option name="PARSE_HTML_ANCHOR_ID" value="false" />
<option name="PLANTUML_FENCED_CODE" value="false" />
<option name="PUML_FENCED_CODE" value="false" />
<option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
</ParserOptions>
</ParserSettings>
<HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true" embedImages="false" embedHttpImages="false" imageUriSerials="false" addDocTypeHtml="true" noParaTags="false" plantUmlConversion="0" mathConversion="0">
<GeneratorProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
</GeneratorProvider>
<headerTop />
<headerBottom />
<bodyTop />
<bodyBottom />
</HtmlSettings>
<CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssUriSerial="true" isCssTextEnabled="false" isDynamicPageWidth="true">
<StylesheetProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
</StylesheetProvider>
<ScriptProviders />
<cssText />
<cssUriHistory />
</CssSettings>
<AnnotatorSettings targetHasSpaces="true" linkCaseMismatch="true" wikiCaseMismatch="true" wikiLinkHasDashes="true" notUnderWikiHome="true" targetNotWikiPageExt="true" notUnderSourceWikiHome="true" targetNameHasAnchor="true" targetPathHasAnchor="true" wikiLinkHasSlash="true" wikiLinkHasSubdir="true" wikiLinkHasOnlyAnchor="true" linkTargetsWikiHasExt="true" linkTargetsWikiHasBadExt="true" notUnderSameRepo="true" targetNotUnderVcs="false" linkNeedsExt="true" linkHasBadExt="true" linkTargetNeedsExt="true" linkTargetHasBadExt="true" wikiLinkNotInWiki="true" imageTargetNotInRaw="true" repoRelativeAcrossVcsRoots="true" multipleWikiTargetsMatch="true" unresolvedLinkReference="true" linkIsIgnored="true" anchorIsIgnored="true" anchorIsUnresolved="true" anchorLineReferenceIsUnresolved="true" anchorLineReferenceFormat="true" anchorHasDuplicates="true" abbreviationDuplicates="true" abbreviationNotUsed="true" attributeIdDuplicateDefinition="true" attributeIdNotUsed="true" footnoteDuplicateDefinition="true" footnoteUnresolved="true" footnoteDuplicates="true" footnoteNotUsed="true" macroDuplicateDefinition="true" macroUnresolved="true" macroDuplicates="true" macroNotUsed="true" referenceDuplicateDefinition="true" referenceUnresolved="true" referenceDuplicates="true" referenceNotUsed="true" referenceUnresolvedNumericId="true" enumRefDuplicateDefinition="true" enumRefUnresolved="true" enumRefDuplicates="true" enumRefNotUsed="true" enumRefLinkUnresolved="true" enumRefLinkDuplicates="true" simTocUpdateNeeded="true" simTocTitleSpaceNeeded="true" />
<HtmlExportSettings updateOnSave="false" parentDir="" targetDir="" cssDir="css" scriptDir="js" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetPathType="2" targetExt="" useTargetExt="false" noCssNoScripts="false" useElementStyleAttribute="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" linkFormatType="HTTP_ABSOLUTE" />
<LinkMapSettings>
<textMaps />
</LinkMapSettings>
</component>
</project>

View File

@@ -0,0 +1,3 @@
<component name="MarkdownNavigator.ProfileManager">
<settings default="" pdf-export="" plain-text-search-scope="Project Files" />
</component>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="com.jetbrains.rider.android.RiderAndroidMiscFileCreationComponent">
<option name="ENSURE_MISC_FILE_EXISTS" value="true" />
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RiderProjectSettingsUpdater">
<option name="vcsConfiguration" value="2" />
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@@ -4,7 +4,7 @@
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright (c) 2016 © Claunia.com
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -24,86 +24,104 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using NUnit.Framework;
namespace Claunia.Encoding.Tests;
namespace Claunia.Encoding.Tests
[TestFixture]
public class Atascii
{
[TestFixture]
public class ATASCII
const string PUNCTUATIONS = "!\"#$%&'()*+,-./:;<=>?@[\\]^_|";
readonly byte[] _punctuationsBytes =
{
const string Punctuations = "!\"#$%&'()*+,-./:;<=>?@[\\]^_|";
readonly byte[] PunctuationsBytes = { 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E,
0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x7C };
const string Digits = "0123456789";
readonly byte[] DigitsBytes = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 };
const string UpperLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
readonly byte[] UpperLatinBytes = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A };
const string LowerLatin = "abcdefghijklmnopqrstuvwxyz";
readonly byte[] LowerLatinBytes = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74,
0x75, 0x76, 0x77, 0x78, 0x79, 0x7A };
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C,
0x3D, 0x3E, 0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x7C
};
const string DIGITS = "0123456789";
readonly byte[] _digitsBytes =
{
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39
};
const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
readonly byte[] _upperLatinBytes =
{
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A
};
const string LOWER_LATIN = "abcdefghijklmnopqrstuvwxyz";
readonly byte[] _lowerLatinBytes =
{
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72,
0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A
};
const string Graphics = "├┘┤┐╱╲◢▗◣▝▘▂▖┌─┼●▄▎┬┴▌└";
readonly byte[] GraphicsBytes = { 0x01, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0E, 0x0F, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1A};
const string Arrows = "↑↓←→↰◀▶";
readonly byte[] ArrowsBytes = { 0x1C, 0x1D, 0x1E, 0x1F, 0x7D, 0x7E, 0x7F };
const string Decks = "♥♣♦♠";
readonly byte[] DecksBytes = { 0x00, 0x10, 0x60, 0x7B };
const string GRAPHICS = "├┘┤┐╱╲◢▗◣▝▘▂▖┌─┼●▄▎┬┴▌└";
readonly byte[] _graphicsBytes =
{
0x01, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0E, 0x0F, 0x11, 0x12, 0x13, 0x14, 0x15,
0x16, 0x17, 0x18, 0x19, 0x1A
};
const string ARROWS = "↑↓←→🢰◀▶";
readonly byte[] _arrowsBytes =
{
0x1C, 0x1D, 0x1E, 0x1F, 0x7D, 0x7E, 0x7F
};
const string DECKS = "♥♣♦♠";
readonly byte[] _decksBytes =
{
0x00, 0x10, 0x60, 0x7B
};
[Test]
public void UnicodeToAtari()
{
byte[] byteArray;
[Test]
public void AtariPangrams()
{
byte[] byteArray;
string testString;
byteArray = Encoding.AtariEncoding.GetBytes(Punctuations);
Assert.AreEqual(PunctuationsBytes, byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(Digits);
Assert.AreEqual(DigitsBytes, byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(UpperLatin);
Assert.AreEqual(UpperLatinBytes, byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(LowerLatin);
Assert.AreEqual(LowerLatinBytes, byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(Pangrams.ENGLISH);
testString = Encoding.AtariEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.ENGLISH, testString);
}
byteArray = Encoding.AtariEncoding.GetBytes(Graphics);
Assert.AreEqual(GraphicsBytes, byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(Arrows);
Assert.AreEqual(ArrowsBytes, byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(Decks);
Assert.AreEqual(DecksBytes, byteArray);
}
[Test]
public void AtariToUnicode()
{
string testString;
[Test]
public void AtariToUnicode()
{
string testString;
testString = Encoding.AtariEncoding.GetString(_punctuationsBytes);
Assert.AreEqual(PUNCTUATIONS, testString);
testString = Encoding.AtariEncoding.GetString(_digitsBytes);
Assert.AreEqual(DIGITS, testString);
testString = Encoding.AtariEncoding.GetString(_upperLatinBytes);
Assert.AreEqual(UPPER_LATIN, testString);
testString = Encoding.AtariEncoding.GetString(_lowerLatinBytes);
Assert.AreEqual(LOWER_LATIN, testString);
testString = Encoding.AtariEncoding.GetString(PunctuationsBytes);
Assert.AreEqual(Punctuations, testString);
testString = Encoding.AtariEncoding.GetString(DigitsBytes);
Assert.AreEqual(Digits, testString);
testString = Encoding.AtariEncoding.GetString(UpperLatinBytes);
Assert.AreEqual(UpperLatin, testString);
testString = Encoding.AtariEncoding.GetString(LowerLatinBytes);
Assert.AreEqual(LowerLatin, testString);
testString = Encoding.AtariEncoding.GetString(_graphicsBytes);
Assert.AreEqual(GRAPHICS, testString);
testString = Encoding.AtariEncoding.GetString(_arrowsBytes);
Assert.AreEqual(ARROWS, testString);
testString = Encoding.AtariEncoding.GetString(_decksBytes);
Assert.AreEqual(DECKS, testString);
}
testString = Encoding.AtariEncoding.GetString(GraphicsBytes);
Assert.AreEqual(Graphics, testString);
testString = Encoding.AtariEncoding.GetString(ArrowsBytes);
Assert.AreEqual(Arrows, testString);
testString = Encoding.AtariEncoding.GetString(DecksBytes);
Assert.AreEqual(Decks, testString);
}
[Test]
public void UnicodeToAtari()
{
byte[] byteArray;
[Test]
public void AtariPangrams()
{
byte[] byteArray;
string testString;
byteArray = Encoding.AtariEncoding.GetBytes(PUNCTUATIONS);
Assert.AreEqual(_punctuationsBytes, byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(DIGITS);
Assert.AreEqual(_digitsBytes, byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(UPPER_LATIN);
Assert.AreEqual(_upperLatinBytes, byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(LOWER_LATIN);
Assert.AreEqual(_lowerLatinBytes, byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(Pangrams.English);
testString = Encoding.AtariEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.English, testString);
}
byteArray = Encoding.AtariEncoding.GetBytes(GRAPHICS);
Assert.AreEqual(_graphicsBytes, byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(ARROWS);
Assert.AreEqual(_arrowsBytes, byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(DECKS);
Assert.AreEqual(_decksBytes, byteArray);
}
}

View File

@@ -4,7 +4,7 @@
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright (c) 2016 © Claunia.com
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -24,187 +24,235 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using NUnit.Framework;
using System.Runtime.InteropServices;
namespace Claunia.Encoding.Tests;
namespace Claunia.Encoding.Tests
[TestFixture]
public class AtariSt
{
[TestFixture]
public class AtariST
const string PUNCTUATIONS = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
readonly byte[] _punctuationsBytes =
{
const string Punctuations = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
readonly byte[] PunctuationsBytes = { 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E,
0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x7B, 0x7C, 0x7D, 0x7E };
const string Digits = "0123456789";
readonly byte[] DigitsBytes = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 };
const string UpperLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
readonly byte[] UpperLatinBytes = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A };
const string LowerLatin = "abcdefghijklmnopqrstuvwxyz";
readonly byte[] LowerLatinBytes = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74,
0x75, 0x76, 0x77, 0x78, 0x79, 0x7A };
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C,
0x3D, 0x3E, 0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x7B, 0x7C, 0x7D, 0x7E
};
const string DIGITS = "0123456789";
readonly byte[] _digitsBytes =
{
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39
};
const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
readonly byte[] _upperLatinBytes =
{
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A
};
const string LOWER_LATIN = "abcdefghijklmnopqrstuvwxyz";
readonly byte[] _lowerLatinBytes =
{
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72,
0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A
};
const string Spanish = "¡¿áéíóúüñÉÜÑ";
readonly byte[] SpanishBytes = { 0xAD, 0xA8, 0xA0, 0x82, 0xA1, 0xA2, 0xA3, 0x81, 0xA4, 0x90, 0x9A, 0xA5 };
const string French = "éÉàèùÀâêîôûëïüÿçÇœŒæÆ";
readonly byte[] FrenchBytes = { 0x82, 0x90, 0x85, 0x8A, 0x97, 0xB6, 0x83, 0x88, 0x8C, 0x93, 0x96, 0x89, 0x8B, 0x81, 0x98, 0x87, 0x80, 0xB4, 0xB5, 0x91, 0x92 };
const string German = "äöüßÄÖÜ";
readonly byte[] GermanBytes = { 0x84, 0x94, 0x81, 0x9E, 0x8E, 0x99, 0x9A };
const string Norwegian = "æøåÆØÅ";
readonly byte[] NorwegianBytes = { 0x91, 0xB3, 0x86, 0x92, 0xB2, 0x8F };
const string Portuguese = "áéíóúÉâêôãõÃÕçÇ";
readonly byte[] PortugueseBytes = { 0xA0, 0x82, 0xA1, 0xA2, 0xA3, 0x90, 0x83, 0x88, 0x93, 0xB0, 0xB1, 0xB7, 0xB8, 0x87, 0x80 };
const string Dutch = "ijIJ";
readonly byte[] DutchBytes = { 0xC0, 0xC1 };
const string Hebrew = "אבגדהוזחטיכלמנסעפצקרשתןךםףץ";
readonly byte[] HebrewBytes = { 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6,
0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC};
const string Greek = "αβΓπΣσµτΦΘΩδ¯";
readonly byte[] GreekBytes = { 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xFF };
const string SPANISH = "¡¿áéíóúüñÉÜÑ";
readonly byte[] _spanishBytes =
{
0xAD, 0xA8, 0xA0, 0x82, 0xA1, 0xA2, 0xA3, 0x81, 0xA4, 0x90, 0x9A, 0xA5
};
const string FRENCH = "éÉàèùÀâêîôûëïüÿçÇœŒæÆ";
readonly byte[] _frenchBytes =
{
0x82, 0x90, 0x85, 0x8A, 0x97, 0xB6, 0x83, 0x88, 0x8C, 0x93, 0x96, 0x89, 0x8B, 0x81, 0x98, 0x87, 0x80, 0xB4,
0xB5, 0x91, 0x92
};
const string GERMAN = "äöüßÄÖÜ";
readonly byte[] _germanBytes =
{
0x84, 0x94, 0x81, 0x9E, 0x8E, 0x99, 0x9A
};
const string NORWEGIAN = "æøåÆØÅ";
readonly byte[] _norwegianBytes =
{
0x91, 0xB3, 0x86, 0x92, 0xB2, 0x8F
};
const string PORTUGUESE = "áéíóúÉâêôãõÃÕçÇ";
readonly byte[] _portugueseBytes =
{
0xA0, 0x82, 0xA1, 0xA2, 0xA3, 0x90, 0x83, 0x88, 0x93, 0xB0, 0xB1, 0xB7, 0xB8, 0x87, 0x80
};
const string DUTCH = "ijIJ";
readonly byte[] _dutchBytes =
{
0xC0, 0xC1
};
const string HEBREW = "אבגדהוזחטיכלמנסעפצקרשתןךםףץ";
readonly byte[] _hebrewBytes =
{
0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3,
0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC
};
const string GREEK = "αβΓπΣσµτΦΘΩδ¯";
readonly byte[] _greekBytes =
{
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xFF
};
const string TYPOGRAPHIC = "ªº«»¨´†¶©®™§°∙·";
readonly byte[] _typographicBytes =
{
0xA6, 0xA7, 0xAE, 0xAF, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xDD, 0xF8, 0xF9, 0xFA
};
const string CURRENCY = "¢£¥ƒ";
readonly byte[] _currencyBytes =
{
0x9B, 0x9C, 0x9D, 0x9F
};
const string MATHEMATICS = "⌐¬½¼∧∞∮ϕ∈∩≡±≥≤⌠⌡÷≈√ⁿ²³";
readonly byte[] _mathematicsBytes =
{
0xA9, 0xAA, 0xAB, 0xAC, 0xDE, 0xDF, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
0xFB, 0xFC, 0xFD, 0xFE
};
const string SYMBOLS = "⇧⇩⇨⇦🮽✓♪ə";
readonly byte[] _symbolsBytes =
{
0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x0B, 0x1A
};
[Test]
public void AtariStPangrams()
{
byte[] byteArray;
string testString;
byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.BASQUE);
testString = Encoding.AtariStEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.BASQUE, testString);
byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.DANISH);
testString = Encoding.AtariStEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.DANISH, testString);
byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.ENGLISH);
testString = Encoding.AtariStEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.ENGLISH, testString);
byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.FINNISH);
testString = Encoding.AtariStEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.FINNISH, testString);
byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.FRENCH);
testString = Encoding.AtariStEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.FRENCH, testString);
byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.GALICIAN);
testString = Encoding.AtariStEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.GALICIAN, testString);
byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.GERMAN);
testString = Encoding.AtariStEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.GERMAN, testString);
byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.HEBREW);
testString = Encoding.AtariStEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.HEBREW, testString);
byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.NORWEGIAN);
testString = Encoding.AtariStEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.NORWEGIAN, testString);
byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.PORTUGUESE);
testString = Encoding.AtariStEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.PORTUGUESE, testString);
byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.SPANISH);
testString = Encoding.AtariStEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.SPANISH, testString);
byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.SWEDISH);
testString = Encoding.AtariStEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.SWEDISH, testString);
}
[Test]
public void AtariStToUnicode()
{
string testString;
testString = Encoding.AtariStEncoding.GetString(_punctuationsBytes);
Assert.AreEqual(PUNCTUATIONS, testString);
testString = Encoding.AtariStEncoding.GetString(_digitsBytes);
Assert.AreEqual(DIGITS, testString);
testString = Encoding.AtariStEncoding.GetString(_upperLatinBytes);
Assert.AreEqual(UPPER_LATIN, testString);
testString = Encoding.AtariStEncoding.GetString(_lowerLatinBytes);
Assert.AreEqual(LOWER_LATIN, testString);
testString = Encoding.AtariStEncoding.GetString(_spanishBytes);
Assert.AreEqual(SPANISH, testString);
testString = Encoding.AtariStEncoding.GetString(_frenchBytes);
Assert.AreEqual(FRENCH, testString);
testString = Encoding.AtariStEncoding.GetString(_germanBytes);
Assert.AreEqual(GERMAN, testString);
testString = Encoding.AtariStEncoding.GetString(_norwegianBytes);
Assert.AreEqual(NORWEGIAN, testString);
testString = Encoding.AtariStEncoding.GetString(_portugueseBytes);
Assert.AreEqual(PORTUGUESE, testString);
testString = Encoding.AtariStEncoding.GetString(_dutchBytes);
Assert.AreEqual(DUTCH, testString);
testString = Encoding.AtariStEncoding.GetString(_hebrewBytes);
Assert.AreEqual(HEBREW, testString);
testString = Encoding.AtariStEncoding.GetString(_greekBytes);
Assert.AreEqual(GREEK, testString);
testString = Encoding.AtariStEncoding.GetString(_typographicBytes);
Assert.AreEqual(TYPOGRAPHIC, testString);
testString = Encoding.AtariStEncoding.GetString(_currencyBytes);
Assert.AreEqual(CURRENCY, testString);
testString = Encoding.AtariStEncoding.GetString(_mathematicsBytes);
Assert.AreEqual(MATHEMATICS, testString);
testString = Encoding.AtariStEncoding.GetString(_symbolsBytes);
Assert.AreEqual(SYMBOLS, testString);
const string Typographic = "ªº«»¨´†¶©®™§°∙·";
readonly byte[] TypographicBytes = { 0xA6, 0xA7, 0xAE, 0xAF, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xDD, 0xF8, 0xF9, 0xFA };
const string Currency = "¢£¥ƒ";
readonly byte[] CurrencyBytes = { 0x9B, 0x9C, 0x9D, 0x9F };
const string Mathematics = "⌐¬½¼∧∞∮ϕ∈∩≡±≥≤⌠⌡÷≈√ⁿ²³";
readonly byte[] MathematicsBytes = { 0xA9, 0xAA, 0xAB, 0xAC, 0xDE, 0xDF, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xFB, 0xFC,
0xFD, 0xFE};
const string Symbols = "⇧⇩⇨⇦❎✓♪ə";
readonly byte[] SymbolsBytes = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x0B, 0x1A };
// TODO: 0x09 => U+1F552, 0x0A => U+1F514
/*const string SymbolsUnicode32 = "\ud83d\udd52\ud83d\udd14";
readonly byte[] SymbolsUnicode32Bytes = { 0x09, 0x0A };*/
/*testString = Encoding.AtariSTEncoding.GetString(SymbolsUnicode32Bytes);
Assert.AreEqual(SymbolsUnicode32, testString);*/
}
[Test]
public void UnicodeToAtariST()
{
byte[] byteArray;
// TODO: 0x09 => U+1F552, 0x0A => U+1F514
/*const string SymbolsUnicode32 = "\ud83d\udd52\ud83d\udd14";
readonly byte[] SymbolsUnicode32Bytes = { 0x09, 0x0A };*/
byteArray = Encoding.AtariSTEncoding.GetBytes(Punctuations);
Assert.AreEqual(PunctuationsBytes, byteArray);
byteArray = Encoding.AtariSTEncoding.GetBytes(Digits);
Assert.AreEqual(DigitsBytes, byteArray);
byteArray = Encoding.AtariSTEncoding.GetBytes(UpperLatin);
Assert.AreEqual(UpperLatinBytes, byteArray);
byteArray = Encoding.AtariSTEncoding.GetBytes(LowerLatin);
Assert.AreEqual(LowerLatinBytes, byteArray);
[Test]
public void UnicodeToAtariSt()
{
byte[] byteArray;
byteArray = Encoding.AtariSTEncoding.GetBytes(Spanish);
Assert.AreEqual(SpanishBytes, byteArray);
byteArray = Encoding.AtariSTEncoding.GetBytes(French);
Assert.AreEqual(FrenchBytes, byteArray);
byteArray = Encoding.AtariSTEncoding.GetBytes(German);
Assert.AreEqual(GermanBytes, byteArray);
byteArray = Encoding.AtariSTEncoding.GetBytes(Norwegian);
Assert.AreEqual(NorwegianBytes, byteArray);
byteArray = Encoding.AtariSTEncoding.GetBytes(Portuguese);
Assert.AreEqual(PortugueseBytes, byteArray);
byteArray = Encoding.AtariSTEncoding.GetBytes(Dutch);
Assert.AreEqual(DutchBytes, byteArray);
byteArray = Encoding.AtariSTEncoding.GetBytes(Hebrew);
Assert.AreEqual(HebrewBytes, byteArray);
byteArray = Encoding.AtariSTEncoding.GetBytes(Greek);
Assert.AreEqual(GreekBytes, byteArray);
byteArray = Encoding.AtariStEncoding.GetBytes(PUNCTUATIONS);
Assert.AreEqual(_punctuationsBytes, byteArray);
byteArray = Encoding.AtariStEncoding.GetBytes(DIGITS);
Assert.AreEqual(_digitsBytes, byteArray);
byteArray = Encoding.AtariStEncoding.GetBytes(UPPER_LATIN);
Assert.AreEqual(_upperLatinBytes, byteArray);
byteArray = Encoding.AtariStEncoding.GetBytes(LOWER_LATIN);
Assert.AreEqual(_lowerLatinBytes, byteArray);
byteArray = Encoding.AtariSTEncoding.GetBytes(Typographic);
Assert.AreEqual(TypographicBytes, byteArray);
byteArray = Encoding.AtariSTEncoding.GetBytes(Currency);
Assert.AreEqual(CurrencyBytes, byteArray);
byteArray = Encoding.AtariSTEncoding.GetBytes(Mathematics);
Assert.AreEqual(MathematicsBytes, byteArray);
byteArray = Encoding.AtariSTEncoding.GetBytes(Symbols);
Assert.AreEqual(SymbolsBytes, byteArray);
// TODO: 0x09 => U+1F552, 0x0A => U+1F514
/*byteArray = Encoding.AtariSTEncoding.GetBytes(SymbolsUnicode32);
Assert.AreEqual(SymbolsUnicode32Bytes, byteArray);*/
}
byteArray = Encoding.AtariStEncoding.GetBytes(SPANISH);
Assert.AreEqual(_spanishBytes, byteArray);
byteArray = Encoding.AtariStEncoding.GetBytes(FRENCH);
Assert.AreEqual(_frenchBytes, byteArray);
byteArray = Encoding.AtariStEncoding.GetBytes(GERMAN);
Assert.AreEqual(_germanBytes, byteArray);
byteArray = Encoding.AtariStEncoding.GetBytes(NORWEGIAN);
Assert.AreEqual(_norwegianBytes, byteArray);
byteArray = Encoding.AtariStEncoding.GetBytes(PORTUGUESE);
Assert.AreEqual(_portugueseBytes, byteArray);
byteArray = Encoding.AtariStEncoding.GetBytes(DUTCH);
Assert.AreEqual(_dutchBytes, byteArray);
byteArray = Encoding.AtariStEncoding.GetBytes(HEBREW);
Assert.AreEqual(_hebrewBytes, byteArray);
byteArray = Encoding.AtariStEncoding.GetBytes(GREEK);
Assert.AreEqual(_greekBytes, byteArray);
[Test]
public void AtariSTToUnicode()
{
string testString;
byteArray = Encoding.AtariStEncoding.GetBytes(TYPOGRAPHIC);
Assert.AreEqual(_typographicBytes, byteArray);
byteArray = Encoding.AtariStEncoding.GetBytes(CURRENCY);
Assert.AreEqual(_currencyBytes, byteArray);
byteArray = Encoding.AtariStEncoding.GetBytes(MATHEMATICS);
Assert.AreEqual(_mathematicsBytes, byteArray);
byteArray = Encoding.AtariStEncoding.GetBytes(SYMBOLS);
Assert.AreEqual(_symbolsBytes, byteArray);
testString = Encoding.AtariSTEncoding.GetString(PunctuationsBytes);
Assert.AreEqual(Punctuations, testString);
testString = Encoding.AtariSTEncoding.GetString(DigitsBytes);
Assert.AreEqual(Digits, testString);
testString = Encoding.AtariSTEncoding.GetString(UpperLatinBytes);
Assert.AreEqual(UpperLatin, testString);
testString = Encoding.AtariSTEncoding.GetString(LowerLatinBytes);
Assert.AreEqual(LowerLatin, testString);
testString = Encoding.AtariSTEncoding.GetString(SpanishBytes);
Assert.AreEqual(Spanish, testString);
testString = Encoding.AtariSTEncoding.GetString(FrenchBytes);
Assert.AreEqual(French, testString);
testString = Encoding.AtariSTEncoding.GetString(GermanBytes);
Assert.AreEqual(German, testString);
testString = Encoding.AtariSTEncoding.GetString(NorwegianBytes);
Assert.AreEqual(Norwegian, testString);
testString = Encoding.AtariSTEncoding.GetString(PortugueseBytes);
Assert.AreEqual(Portuguese, testString);
testString = Encoding.AtariSTEncoding.GetString(DutchBytes);
Assert.AreEqual(Dutch, testString);
testString = Encoding.AtariSTEncoding.GetString(HebrewBytes);
Assert.AreEqual(Hebrew, testString);
testString = Encoding.AtariSTEncoding.GetString(GreekBytes);
Assert.AreEqual(Greek, testString);
testString = Encoding.AtariSTEncoding.GetString(TypographicBytes);
Assert.AreEqual(Typographic, testString);
testString = Encoding.AtariSTEncoding.GetString(CurrencyBytes);
Assert.AreEqual(Currency, testString);
testString = Encoding.AtariSTEncoding.GetString(MathematicsBytes);
Assert.AreEqual(Mathematics, testString);
testString = Encoding.AtariSTEncoding.GetString(SymbolsBytes);
Assert.AreEqual(Symbols, testString);
// TODO: 0x09 => U+1F552, 0x0A => U+1F514
/*testString = Encoding.AtariSTEncoding.GetString(SymbolsUnicode32Bytes);
Assert.AreEqual(SymbolsUnicode32, testString);*/
}
[Test]
public void AtariSTPangrams()
{
byte[] byteArray;
string testString;
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Basque);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Basque, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Danish);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Danish, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.English);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.English, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Finnish);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Finnish, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.French);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.French, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Galician);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Galician, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.German);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.German, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Hebrew);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Hebrew, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Norwegian);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Norwegian, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Portuguese);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Portuguese, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Spanish);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Spanish, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Swedish);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Swedish, testString);
}
// TODO: 0x09 => U+1F552, 0x0A => U+1F514
/*byteArray = Encoding.AtariSTEncoding.GetBytes(SymbolsUnicode32);
Assert.AreEqual(SymbolsUnicode32Bytes, byteArray);*/
}
}

View File

@@ -1,50 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{94C931C5-EA3A-4AB2-80F5-1BE083C237C3}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Claunia.Encoding.Tests</RootNamespace>
<AssemblyName>Claunia.Encoding.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<ReleaseVersion>1.9.2</ReleaseVersion>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="LisaRoman.cs" />
<Compile Include="ATASCII.cs" />
<Compile Include="AtariST.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Claunia.Encoding\Claunia.Encoding.csproj">
<Project>{85DA90BC-9F49-4579-B4D1-4FF2D5925D7F}</Project>
<Name>Claunia.Encoding</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4"/>
<PackageReference Include="NUnit" Version="3.13.2"/>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,72 @@
//
// GetEncs.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2017-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Claunia.Encoding.Tests;
[TestFixture]
public class GetEncs
{
[Test]
// Well basically this is taken from MSDN's documentation :p
public void GetAllEncs()
{
// Print the header.
Console.Write("CodePage identifier and name ");
Console.Write("BrDisp BrSave ");
Console.Write("MNDisp MNSave ");
Console.WriteLine("1-Byte ReadOnly ");
// For every encoding, get the property values.
foreach(EncodingInfo ei in Encoding.GetEncodings())
{
Encoding e = ei.GetEncoding();
Console.Write("{0,-6} {1,-25} ", ei.CodePage, ei.Name);
Console.Write("{0,-8} {1,-8} ", e.IsBrowserDisplay, e.IsBrowserSave);
Console.Write("{0,-8} {1,-8} ", e.IsMailNewsDisplay, e.IsMailNewsSave);
Console.WriteLine("{0,-8} {1,-8} ", e.IsSingleByte, e.IsReadOnly);
}
}
[Test]
// Well basically this is taken from MSDN's documentation :p
public void GetExternalEncoding()
{
System.Text.Encoding e = Encoding.GetEncoding("iso8859-1");
}
[Test]
// Well basically this is taken from MSDN's documentation :p
public void GetInternalEncoding()
{
System.Text.Encoding e = Encoding.GetEncoding("lisa");
}
}

View File

@@ -0,0 +1 @@
global using NUnit.Framework;

View File

@@ -4,7 +4,7 @@
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright (c) 2016 © Claunia.com
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -24,154 +24,189 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using NUnit.Framework;
namespace Claunia.Encoding.Tests;
namespace Claunia.Encoding.Tests
[TestFixture]
public class LisaRoman
{
[TestFixture]
public class LisaRoman
const string PUNCTUATIONS = "!\"#$%&()*+,-./:;<=>?@[\\]^_{|}~";
readonly byte[] _punctuationsBytes =
{
const string Punctuations = "!\"#$%&()*+,-./:;<=>?@[\\]^_{|}~";
readonly byte[] PunctuationsBytes = { 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E,
0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x7B, 0x7C, 0x7D, 0x7E };
const string Digits = "0123456789";
readonly byte[] DigitsBytes = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 };
const string UpperLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
readonly byte[] UpperLatinBytes = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A };
const string LowerLatin = "abcdefghijklmnopqrstuvwxyz";
readonly byte[] LowerLatinBytes = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74,
0x75, 0x76, 0x77, 0x78, 0x79, 0x7A };
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, 0x3D,
0x3E, 0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x7B, 0x7C, 0x7D, 0x7E
};
const string DIGITS = "0123456789";
readonly byte[] _digitsBytes =
{
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39
};
const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
readonly byte[] _upperLatinBytes =
{
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A
};
const string LOWER_LATIN = "abcdefghijklmnopqrstuvwxyz";
readonly byte[] _lowerLatinBytes =
{
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72,
0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A
};
const string Spanish = "¡¿áéíóúüñÉÜÑ";
readonly byte[] SpanishBytes = { 0xC1, 0xC0, 0x87, 0x8E, 0x92, 0x97, 0x9C, 0x9F, 0x96, 0x83, 0x86, 0x84 };
const string French = "éÉàèùÀâêîôûëïüÿçÇœŒæÆ";
readonly byte[] FrenchBytes = { 0x8E, 0x83, 0x88, 0x8F, 0x9D, 0xCB, 0x89, 0x90, 0x94, 0x99, 0x9E, 0x91, 0x95, 0x9F, 0xD8, 0x8D, 0x82, 0xCF, 0xCE, 0xBE, 0xAE };
const string German = "äöüßÄÖÜ";
readonly byte[] GermanBytes = { 0x8A, 0x9A, 0x9F, 0xA7, 0x80, 0x85, 0x86 };
const string Norwegian = "æøåÆØÅ";
readonly byte[] NorwegianBytes = { 0xBE, 0xBF, 0x8C, 0xAE, 0xAF, 0x81 };
const string Portuguese = "áéíóúÉâêôãõÃÕçÇ";
readonly byte[] PortugueseBytes = { 0x87, 0x8E, 0x92, 0x97, 0x9C, 0x83, 0x89, 0x90, 0x99, 0x8B, 0x9B, 0xCC, 0xCD, 0x8D, 0x82 };
const string SPANISH = "¡¿áéíóúüñÉÜÑ";
readonly byte[] _spanishBytes =
{
0xC1, 0xC0, 0x87, 0x8E, 0x92, 0x97, 0x9C, 0x9F, 0x96, 0x83, 0x86, 0x84
};
const string FRENCH = "éÉàèùÀâêîôûëïüÿçÇœŒæÆ";
readonly byte[] _frenchBytes =
{
0x8E, 0x83, 0x88, 0x8F, 0x9D, 0xCB, 0x89, 0x90, 0x94, 0x99, 0x9E, 0x91, 0x95, 0x9F, 0xD8, 0x8D, 0x82, 0xCF,
0xCE, 0xBE, 0xAE
};
const string GERMAN = "äöüßÄÖÜ";
readonly byte[] _germanBytes =
{
0x8A, 0x9A, 0x9F, 0xA7, 0x80, 0x85, 0x86
};
const string NORWEGIAN = "æøåÆØÅ";
readonly byte[] _norwegianBytes =
{
0xBE, 0xBF, 0x8C, 0xAE, 0xAF, 0x81
};
const string PORTUGUESE = "áéíóúÉâêôãõÃÕçÇ";
readonly byte[] _portugueseBytes =
{
0x87, 0x8E, 0x92, 0x97, 0x9C, 0x83, 0x89, 0x90, 0x99, 0x8B, 0x9B, 0xCC, 0xCD, 0x8D, 0x82
};
const string Typographic = "†°•¶®©™´¨ªº«»…–—“”‘’§";
readonly byte[] TypographicBytes = { 0xA0, 0xA1, 0xA5, 0xA6, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xBB, 0xBC, 0xC7, 0xC8, 0xC9, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xA4};
const string Currency = "¢£¥";
readonly byte[] CurrencyBytes = { 0xA2, 0xA3, 0xB4 };
const string Mathematics = "≠∞±≤≥µ∂∑∏π∫Ω¬√ƒ≈∆÷◊";
readonly byte[] MathematicsBytes = { 0xAD, 0xB0, 0xB1, 0xB2, 0xB3, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBD, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xD6, 0xD7 };
const string TYPOGRAPHIC = "†°•¶®©™´¨ªº«»…–—“”‘’§";
readonly byte[] _typographicBytes =
{
0xA0, 0xA1, 0xA5, 0xA6, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xBB, 0xBC, 0xC7, 0xC8, 0xC9, 0xD0, 0xD1, 0xD2, 0xD3,
0xD4, 0xD5, 0xA4
};
const string CURRENCY = "¢£¥";
readonly byte[] _currencyBytes =
{
0xA2, 0xA3, 0xB4
};
const string MATHEMATICS = "≠∞±≤≥µ∂∑∏π∫Ω¬√ƒ≈∆÷◊";
readonly byte[] _mathematicsBytes =
{
0xAD, 0xB0, 0xB1, 0xB2, 0xB3, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBD, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xD6, 0xD7
};
[Test]
public void UnicodeToLisa()
{
byte[] byteArray;
[Test]
public void LisaPangrams()
{
byte[] byteArray;
string testString;
byteArray = Encoding.LisaEncoding.GetBytes(Punctuations);
Assert.AreEqual(PunctuationsBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(Digits);
Assert.AreEqual(DigitsBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(UpperLatin);
Assert.AreEqual(UpperLatinBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(LowerLatin);
Assert.AreEqual(LowerLatinBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.BASQUE);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.BASQUE, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.BRETON);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.BRETON, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.DANISH);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.DANISH, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.DUTCH);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.DUTCH, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.ENGLISH);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.ENGLISH, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.FINNISH);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.FINNISH, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.FRENCH);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.FRENCH, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.GALICIAN);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.GALICIAN, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.GERMAN);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.GERMAN, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.NORWEGIAN);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.NORWEGIAN, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.PORTUGUESE);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.PORTUGUESE, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.SPANISH);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.SPANISH, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.SWEDISH);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.SWEDISH, testString);
}
byteArray = Encoding.LisaEncoding.GetBytes(Spanish);
Assert.AreEqual(SpanishBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(French);
Assert.AreEqual(FrenchBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(German);
Assert.AreEqual(GermanBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(Norwegian);
Assert.AreEqual(NorwegianBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(Portuguese);
Assert.AreEqual(PortugueseBytes, byteArray);
[Test]
public void LisaToUnicode()
{
string testString;
byteArray = Encoding.LisaEncoding.GetBytes(Typographic);
Assert.AreEqual(TypographicBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(Currency);
Assert.AreEqual(CurrencyBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(Mathematics);
Assert.AreEqual(MathematicsBytes, byteArray);
}
testString = Encoding.LisaEncoding.GetString(_punctuationsBytes);
Assert.AreEqual(PUNCTUATIONS, testString);
testString = Encoding.LisaEncoding.GetString(_digitsBytes);
Assert.AreEqual(DIGITS, testString);
testString = Encoding.LisaEncoding.GetString(_upperLatinBytes);
Assert.AreEqual(UPPER_LATIN, testString);
testString = Encoding.LisaEncoding.GetString(_lowerLatinBytes);
Assert.AreEqual(LOWER_LATIN, testString);
[Test]
public void LisaToUnicode()
{
string testString;
testString = Encoding.LisaEncoding.GetString(_spanishBytes);
Assert.AreEqual(SPANISH, testString);
testString = Encoding.LisaEncoding.GetString(_frenchBytes);
Assert.AreEqual(FRENCH, testString);
testString = Encoding.LisaEncoding.GetString(_germanBytes);
Assert.AreEqual(GERMAN, testString);
testString = Encoding.LisaEncoding.GetString(_norwegianBytes);
Assert.AreEqual(NORWEGIAN, testString);
testString = Encoding.LisaEncoding.GetString(_portugueseBytes);
Assert.AreEqual(PORTUGUESE, testString);
testString = Encoding.LisaEncoding.GetString(PunctuationsBytes);
Assert.AreEqual(Punctuations, testString);
testString = Encoding.LisaEncoding.GetString(DigitsBytes);
Assert.AreEqual(Digits, testString);
testString = Encoding.LisaEncoding.GetString(UpperLatinBytes);
Assert.AreEqual(UpperLatin, testString);
testString = Encoding.LisaEncoding.GetString(LowerLatinBytes);
Assert.AreEqual(LowerLatin, testString);
testString = Encoding.LisaEncoding.GetString(_typographicBytes);
Assert.AreEqual(TYPOGRAPHIC, testString);
testString = Encoding.LisaEncoding.GetString(_currencyBytes);
Assert.AreEqual(CURRENCY, testString);
testString = Encoding.LisaEncoding.GetString(_mathematicsBytes);
Assert.AreEqual(MATHEMATICS, testString);
}
testString = Encoding.LisaEncoding.GetString(SpanishBytes);
Assert.AreEqual(Spanish, testString);
testString = Encoding.LisaEncoding.GetString(FrenchBytes);
Assert.AreEqual(French, testString);
testString = Encoding.LisaEncoding.GetString(GermanBytes);
Assert.AreEqual(German, testString);
testString = Encoding.LisaEncoding.GetString(NorwegianBytes);
Assert.AreEqual(Norwegian, testString);
testString = Encoding.LisaEncoding.GetString(PortugueseBytes);
Assert.AreEqual(Portuguese, testString);
[Test]
public void UnicodeToLisa()
{
byte[] byteArray;
testString = Encoding.LisaEncoding.GetString(TypographicBytes);
Assert.AreEqual(Typographic, testString);
testString = Encoding.LisaEncoding.GetString(CurrencyBytes);
Assert.AreEqual(Currency, testString);
testString = Encoding.LisaEncoding.GetString(MathematicsBytes);
Assert.AreEqual(Mathematics, testString);
}
byteArray = Encoding.LisaEncoding.GetBytes(PUNCTUATIONS);
Assert.AreEqual(_punctuationsBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(DIGITS);
Assert.AreEqual(_digitsBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(UPPER_LATIN);
Assert.AreEqual(_upperLatinBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(LOWER_LATIN);
Assert.AreEqual(_lowerLatinBytes, byteArray);
[Test]
public void LisaPangrams()
{
byte[] byteArray;
string testString;
byteArray = Encoding.LisaEncoding.GetBytes(SPANISH);
Assert.AreEqual(_spanishBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(FRENCH);
Assert.AreEqual(_frenchBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(GERMAN);
Assert.AreEqual(_germanBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(NORWEGIAN);
Assert.AreEqual(_norwegianBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(PORTUGUESE);
Assert.AreEqual(_portugueseBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Basque);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Basque, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Breton);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Breton, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Danish);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Danish, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Dutch);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Dutch, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.English);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.English, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Finnish);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Finnish, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.French);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.French, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Galician);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Galician, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.German);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.German, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Norwegian);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Norwegian, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Portuguese);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Portuguese, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Spanish);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Spanish, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Swedish);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Swedish, testString);
}
byteArray = Encoding.LisaEncoding.GetBytes(TYPOGRAPHIC);
Assert.AreEqual(_typographicBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(CURRENCY);
Assert.AreEqual(_currencyBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(MATHEMATICS);
Assert.AreEqual(_mathematicsBytes, byteArray);
}
}

View File

@@ -0,0 +1,86 @@
//
// LisaRoman.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding.Tests;
[TestFixture]
public class Radix50
{
const string PUNCTUATIONS = " .$%";
readonly byte[] _punctuationsBytes =
{
0b00000001, 0b11000110, 0b11011101
};
const string DIGITS = "0123456789";
readonly byte[] _digitsBytes =
{
0b01111001, 0b11111000, 0b00100001, 0b10001010, 0b00111001, 0b00100101, 0b10011010, 0b01110000
};
const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
readonly byte[] _upperLatinBytes =
{
0b00000100, 0b00100000, 0b11000100, 0b00010100, 0b01100001, 0b11001000, 0b00100100, 0b10100010, 0b11001100,
0b00110100, 0b11100011, 0b11010000, 0b01000101, 0b00100100, 0b11010100, 0b01010101, 0b01100101, 0b11011000,
0b01100101, 0b10100000
};
const string SENTENCE = "THIS IS A TEST$";
const string SENTENCE_PADDED = "THIS IS A TEST$ "; // It gets space padded when decoding is not multiple
readonly byte[] _sentenceBytes =
{
0b01010000, 0b10000010, 0b01010011, 0b00000000, 0b10010100, 0b11000000, 0b00000100, 0b00000101, 0b00000101,
0b01001101, 0b01000110, 0b11000000
};
[Test]
public void RadixToUnicode()
{
string testString;
testString = Encoding.Radix50Encoding.GetString(_punctuationsBytes);
Assert.AreEqual(PUNCTUATIONS, testString);
testString = Encoding.Radix50Encoding.GetString(_digitsBytes);
Assert.AreEqual(DIGITS, testString);
testString = Encoding.Radix50Encoding.GetString(_upperLatinBytes);
Assert.AreEqual(UPPER_LATIN, testString);
testString = Encoding.Radix50Encoding.GetString(_sentenceBytes);
Assert.AreEqual(SENTENCE_PADDED, testString);
}
[Test]
public void UnicodeToRadix()
{
byte[] byteArray;
byteArray = Encoding.Radix50Encoding.GetBytes(PUNCTUATIONS);
Assert.AreEqual(_punctuationsBytes, byteArray);
byteArray = Encoding.Radix50Encoding.GetBytes(DIGITS);
Assert.AreEqual(_digitsBytes, byteArray);
byteArray = Encoding.Radix50Encoding.GetBytes(UPPER_LATIN);
Assert.AreEqual(_upperLatinBytes, byteArray);
byteArray = Encoding.Radix50Encoding.GetBytes(SENTENCE);
Assert.AreEqual(_sentenceBytes, byteArray);
}
}

View File

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.6.4" targetFramework="net45" />
</packages>

View File

@@ -24,35 +24,11 @@ Global
Policies = $0
$0.StandardHeader = $1
$1.Text = @\n${FileName}\n \nAuthor:\n ${AuthorName} <${AuthorEmail}>\n\nCopyright (c) ${Year} ${CopyrightHolder}\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the "Software"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.
$1.IncludeInNewFiles = True
$0.TextStylePolicy = $2
$2.FileWidth = 120
$2.inheritsSet = VisualStudio
$2.inheritsScope = text/plain
$2.scope = text/plain
$2.TabsToSpaces = True
$0.CSharpFormattingPolicy = $3
$3.IndentSwitchSection = True
$3.inheritsSet = Mono
$3.inheritsScope = text/x-csharp
$3.scope = text/x-csharp
$3.NewLinesForBracesInProperties = True
$3.NewLinesForBracesInAccessors = True
$3.NewLinesForBracesInAnonymousMethods = True
$3.NewLinesForBracesInControlBlocks = True
$3.NewLinesForBracesInAnonymousTypes = True
$3.NewLinesForBracesInObjectCollectionArrayInitializers = True
$3.NewLinesForBracesInLambdaExpressionBody = True
$3.NewLineForElse = True
$3.NewLineForCatch = True
$3.NewLineForFinally = True
$3.NewLineForMembersInObjectInit = True
$3.NewLineForMembersInAnonymousTypes = True
$3.NewLineForClausesInQuery = True
$3.SpacingAfterMethodDeclarationName = False
$3.SpaceAfterMethodCallName = False
$3.SpaceAfterControlFlowStatementKeyword = False
$3.SpaceBeforeOpenSquareBracket = False
$3.WrappingPreserveSingleLine = False
$3.WrappingKeepStatementsOnSingleLine = False
version = 1.6
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Claunia/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=NONINFRINGEMENT/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

File diff suppressed because it is too large Load Diff

229
Claunia.Encoding/Apple2.cs Normal file
View File

@@ -0,0 +1,229 @@
//
// Apple II.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents an Apple II character encoding of Unicode characters.</summary>
public sealed class Apple2 : SingleByteEncoding
{
/// <inheritdoc />
public override string BodyName => "apple2";
/// <inheritdoc />
public override int CodePage => 0;
/// <inheritdoc />
public override string EncodingName => "Western European (Apple II)";
/// <inheritdoc />
public override string HeaderName => "apple2";
/// <inheritdoc />
public override string WebName => "";
/// <inheritdoc />
public override int WindowsCodePage => 0;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => false;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The Apple II to Unicode character map.</summary>
protected override char[] CharTable => new[]
{
// 0x00
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
// 0x08
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
// 0x10
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
// 0x18
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0x60
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
// 0x68
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
// 0x70
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
// 0x78
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
// 0x80
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0x88
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0x90
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0x98
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xA0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xA8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xB0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xB8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xC0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xC8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xD0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xD8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xE0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xE8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xF0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xF8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000'
};
/// <summary>Converts a Unicode character to an Apple II character</summary>
/// <returns>Apple II character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(char character) => character switch
{
'\u0020' => 0x20,
'\u0021' => 0x21,
'\u0022' => 0x22,
'\u0023' => 0x23,
'\u0024' => 0x24,
'\u0025' => 0x25,
'\u0026' => 0x26,
'\u0027' => 0x27,
'\u0028' => 0x28,
'\u0029' => 0x29,
'\u002A' => 0x2A,
'\u002B' => 0x2B,
'\u002C' => 0x2C,
'\u002D' => 0x2D,
'\u002E' => 0x2E,
'\u002F' => 0x2F,
'\u0030' => 0x30,
'\u0031' => 0x31,
'\u0032' => 0x32,
'\u0033' => 0x33,
'\u0034' => 0x34,
'\u0035' => 0x35,
'\u0036' => 0x36,
'\u0037' => 0x37,
'\u0038' => 0x38,
'\u0039' => 0x39,
'\u003A' => 0x3A,
'\u003B' => 0x3B,
'\u003C' => 0x3C,
'\u003D' => 0x3D,
'\u003E' => 0x3E,
'\u003F' => 0x3F,
'\u0040' => 0x40,
'\u0041' => 0x41,
'\u0042' => 0x42,
'\u0043' => 0x43,
'\u0044' => 0x44,
'\u0045' => 0x45,
'\u0046' => 0x46,
'\u0047' => 0x47,
'\u0048' => 0x48,
'\u0049' => 0x49,
'\u004A' => 0x4A,
'\u004B' => 0x4B,
'\u004C' => 0x4C,
'\u004D' => 0x4D,
'\u004E' => 0x4E,
'\u004F' => 0x4F,
'\u0050' => 0x50,
'\u0051' => 0x51,
'\u0052' => 0x52,
'\u0053' => 0x53,
'\u0054' => 0x54,
'\u0055' => 0x55,
'\u0056' => 0x56,
'\u0057' => 0x57,
'\u0058' => 0x58,
'\u0059' => 0x59,
'\u005A' => 0x5A,
'\u005B' => 0x5B,
'\u005C' => 0x5C,
'\u005D' => 0x5D,
'\u005E' => 0x5E,
'\u005F' => 0x5F,
_ => 0x3F
};
}

357
Claunia.Encoding/Apple2c.cs Normal file
View File

@@ -0,0 +1,357 @@
//
// Apple IIc.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents an Apple IIc character encoding of Unicode characters.</summary>
public sealed class Apple2c : SingleByteEncodingWithRunes
{
/// <inheritdoc />
public override string BodyName => "apple2c";
/// <inheritdoc />
public override int CodePage => 0;
/// <inheritdoc />
public override string EncodingName => "Western European (Apple IIc)";
/// <inheritdoc />
public override string HeaderName => "apple2c";
/// <inheritdoc />
public override string WebName => "";
/// <inheritdoc />
public override int WindowsCodePage => 0;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => true;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The Apple IIc to Unicode character map. Inverted screen characters are mapped to normal characters.</summary>
protected override Rune[] CharTable => new[]
{
// 0x00
new Rune(0x0000), new Rune(0x0001), new Rune(0x0002), new Rune(0x0003), new Rune(0x0004), new Rune(0x0005),
new Rune(0x0006), new Rune(0x0007),
// 0x08
new Rune(0x0008), new Rune(0x0009), new Rune(0x000A), new Rune(0x000B), new Rune(0x000C), new Rune(0x000D),
new Rune(0x000E), new Rune(0x000F),
// 0x10
new Rune(0x0010), new Rune(0x0011), new Rune(0x0012), new Rune(0x0013), new Rune(0x0014), new Rune(0x0015),
new Rune(0x0016), new Rune(0x0017),
// 0x18
new Rune(0x0018), new Rune(0x0019), new Rune(0x001A), new Rune(0x001B), new Rune(0x001C), new Rune(0x001D),
new Rune(0x001E), new Rune(0x001F),
// 0x20
new Rune(0x0020), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025),
new Rune(0x0026), new Rune(0x0027),
// 0x28
new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D),
new Rune(0x002E), new Rune(0x002F),
// 0x30
new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035),
new Rune(0x0036), new Rune(0x0037),
// 0x38
new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D),
new Rune(0x003E), new Rune(0x003F),
// 0x40
new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045),
new Rune(0x0046), new Rune(0x0047),
// 0x48
new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D),
new Rune(0x004E), new Rune(0x004F),
// 0x50
new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055),
new Rune(0x0056), new Rune(0x0057),
// 0x58
new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x00A3), new Rune(0x005D),
new Rune(0x005E), new Rune(0x005F),
// 0x60
new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065),
new Rune(0x0066), new Rune(0x0067),
// 0x68
new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D),
new Rune(0x006E), new Rune(0x006F),
// 0x70
new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075),
new Rune(0x0076), new Rune(0x0077),
// 0x78
new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D),
new Rune(0x007E), new Rune(0x007F),
// 0x80
new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045),
new Rune(0x0046), new Rune(0x0047),
// 0x88
new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D),
new Rune(0x004E), new Rune(0x004F),
// 0x90
new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055),
new Rune(0x0056), new Rune(0x0057),
// 0x98
new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x00A3), new Rune(0x005D),
new Rune(0x005E), new Rune(0x0020),
// 0xA0
new Rune(0x2588), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025),
new Rune(0x0026), new Rune(0x0027),
// 0xA8
new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D),
new Rune(0x002E), new Rune(0x002F),
// 0xB0
new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035),
new Rune(0x0036), new Rune(0x0037),
// 0xB8
new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035),
new Rune(0x0036), new Rune(0x0037),
// 0xC0
new Rune(0xF8FF), new Rune(0x0000), new Rune(0x1FBB0), new Rune(0x231B), new Rune(0x2713), new Rune(0x1FBB1),
new Rune(0x1FBB2), new Rune(0x1FBB3),
// 0xC8
new Rune(0x2190), new Rune(0x2026), new Rune(0x2193), new Rune(0x2191), new Rune(0x1FB76), new Rune(0x21B5),
new Rune(0x2589), new Rune(0x1FBB5),
// 0xD0
new Rune(0x1FBB6), new Rune(0x1FBB7), new Rune(0x1FBB8), new Rune(0x2500), new Rune(0x1FB7C), new Rune(0x2192),
new Rune(0x2592), new Rune(0x1FB90),
// 0xD8
new Rune(0x1FBB9), new Rune(0x1FBBA), new Rune(0x2595), new Rune(0x25c6), new Rune(0x1FB80), new Rune(0x1FBBB),
new Rune(0x1FBBC), new Rune(0x258F),
// 0xE0
new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065),
new Rune(0x0066), new Rune(0x0067),
// 0xE8
new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D),
new Rune(0x006E), new Rune(0x006F),
// 0xF0
new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075),
new Rune(0x0076), new Rune(0x0077),
// 0xF8
new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D),
new Rune(0x007E), new Rune(0x007F)
};
/// <summary>Converts a Unicode character to an Apple IIc character</summary>
/// <returns>Apple IIc character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(Rune character) => character.Value switch
{
0x0000 => 0x00,
0x0001 => 0x01,
0x0002 => 0x02,
0x0003 => 0x03,
0x0004 => 0x04,
0x0005 => 0x05,
0x0006 => 0x06,
0x0007 => 0x07,
0x0008 => 0x08,
0x0009 => 0x09,
0x000A => 0x0A,
0x000B => 0x0B,
0x000C => 0x0C,
0x000D => 0x0D,
0x000E => 0x0E,
0x000F => 0x0F,
0x0010 => 0x10,
0x0011 => 0x11,
0x0012 => 0x12,
0x0013 => 0x13,
0x0014 => 0x14,
0x0015 => 0x15,
0x0016 => 0x16,
0x0017 => 0x17,
0x0018 => 0x18,
0x0019 => 0x19,
0x001A => 0x1A,
0x001B => 0x1B,
0x001C => 0x1C,
0x001D => 0x1D,
0x001E => 0x1E,
0x001F => 0x1F,
0x0020 => 0x20,
0x0021 => 0x21,
0x0022 => 0x22,
0x0023 => 0x23,
0x0024 => 0x24,
0x0025 => 0x25,
0x0026 => 0x26,
0x0027 => 0x27,
0x0028 => 0x28,
0x0029 => 0x29,
0x002A => 0x2A,
0x002B => 0x2B,
0x002C => 0x2C,
0x002D => 0x2D,
0x002E => 0x2E,
0x002F => 0x2F,
0x0030 => 0x30,
0x0031 => 0x31,
0x0032 => 0x32,
0x0033 => 0x33,
0x0034 => 0x34,
0x0035 => 0x35,
0x0036 => 0x36,
0x0037 => 0x37,
0x0038 => 0x38,
0x0039 => 0x39,
0x003A => 0x3A,
0x003B => 0x3B,
0x003C => 0x3C,
0x003D => 0x3D,
0x003E => 0x3E,
0x003F => 0x3F,
0x0040 => 0x40,
0x0041 => 0x41,
0x0042 => 0x42,
0x0043 => 0x43,
0x0044 => 0x44,
0x0045 => 0x45,
0x0046 => 0x46,
0x0047 => 0x47,
0x0048 => 0x48,
0x0049 => 0x49,
0x004A => 0x4A,
0x004B => 0x4B,
0x004C => 0x4C,
0x004D => 0x4D,
0x004E => 0x4E,
0x004F => 0x4F,
0x0050 => 0x50,
0x0051 => 0x51,
0x0052 => 0x52,
0x0053 => 0x53,
0x0054 => 0x54,
0x0055 => 0x55,
0x0056 => 0x56,
0x0057 => 0x57,
0x0058 => 0x58,
0x0059 => 0x59,
0x005A => 0x5A,
0x005B => 0x5B,
0x00A3 => 0x5C,
0x005D => 0x5D,
0x005E => 0x5E,
0x005F => 0x5F,
0x0060 => 0x60,
0x0061 => 0x61,
0x0062 => 0x62,
0x0063 => 0x63,
0x0064 => 0x64,
0x0065 => 0x65,
0x0066 => 0x66,
0x0067 => 0x67,
0x0068 => 0x68,
0x0069 => 0x69,
0x006A => 0x6A,
0x006B => 0x6B,
0x006C => 0x6C,
0x006D => 0x6D,
0x006E => 0x6E,
0x006F => 0x6F,
0x0070 => 0x70,
0x0071 => 0x71,
0x0072 => 0x72,
0x0073 => 0x73,
0x0074 => 0x74,
0x0075 => 0x75,
0x0076 => 0x76,
0x0077 => 0x77,
0x0078 => 0x78,
0x0079 => 0x79,
0x007A => 0x7A,
0x007B => 0x7B,
0x007C => 0x7C,
0x007D => 0x7D,
0x007E => 0x7E,
0x007F => 0x7F,
0x2588 => 0xA0,
0xF8FF => 0xC0,
0x1FBB0 => 0xC2,
0x231B => 0xC3,
0x2713 => 0xC4,
0x1FBB1 => 0xC5,
0x1FBB2 => 0xC6,
0x1FBB3 => 0xC7,
0x2190 => 0xC8,
0x2026 => 0xC9,
0x2193 => 0xCA,
0x2191 => 0xCB,
0x1FB76 => 0xCC,
0x21B5 => 0xCD,
0x2589 => 0xCE,
0x1FBB5 => 0xCF,
0x1FBB6 => 0xD0,
0x1FBB7 => 0xD1,
0x1FBB8 => 0xD2,
0x2500 => 0xD3,
0x1FB7C => 0xD4,
0x2192 => 0xD5,
0x2592 => 0xD6,
0x1FB90 => 0xD7,
0x1FBB9 => 0xD8,
0x1FBBA => 0xD9,
0x2595 => 0xDA,
0x25C6 => 0xDB,
0x1FB80 => 0xDC,
0x1FBBB => 0xDD,
0x1FBBC => 0xDE,
0x258F => 0xDF,
_ => 0x3F
};
}

290
Claunia.Encoding/Apple2e.cs Normal file
View File

@@ -0,0 +1,290 @@
//
// Apple IIe.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents an Apple IIe character encoding of Unicode characters.</summary>
public class Apple2e : SingleByteEncoding
{
/// <inheritdoc />
public override string BodyName => "apple2e";
/// <inheritdoc />
public override int CodePage => 0;
/// <inheritdoc />
public override string EncodingName => "Western European (Apple IIe)";
/// <inheritdoc />
public override string HeaderName => "apple2e";
/// <inheritdoc />
public override string WebName => "";
/// <inheritdoc />
public override int WindowsCodePage => 0;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => true;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The Apple IIe to Unicode character map.</summary>
protected override char[] CharTable => new[]
{
// 0x00
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
// 0x08
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
// 0x10
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
// 0x18
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
// 0x20
'\u0040', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
// 0x28
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
// 0x30
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
// 0x38
'\u0078', '\u0079', '\u007A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0x40
'\u00A0', '\u2575', '\u2574', '\u2577', '\u2576', '\u2518', '\u2510', '\u250C',
// 0x48
'\u2514', '\u2500', '\u2502', '\u2534', '\u2524', '\u252C', '\u251C', '\u253C',
// 0x50
'\u25E4', '\u25E5', '\u2592', '\u2598', '\u259D', '\u2580', '\u2596', '\u2597',
// 0x58
'\u259A', '\u258C', '\u0000', '\u0000', '\u2190', '\u2191', '\u2192', '\u2193',
// 0x60
'\u03C0', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
// 0x68
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
// 0x70
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
// 0x78
'\u0058', '\u0059', '\u005A', '\u007B', '\u007C', '\u007D', '\u007E', '\u0000',
// 0x80
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0x88
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0x90
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0x98
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xA0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xA8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xB0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xB8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xC0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xC8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xD0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xD8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xE0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xE8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xF0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0xF8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000'
};
/// <summary>Converts a Unicode character to an Apple IIe character</summary>
/// <returns>Apple IIe character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(char character) => character switch
{
'\u0020' => 0x00,
'\u0021' => 0x01,
'\u0022' => 0x02,
'\u0023' => 0x03,
'\u0024' => 0x04,
'\u0025' => 0x05,
'\u0026' => 0x06,
'\u0027' => 0x07,
'\u0028' => 0x08,
'\u0029' => 0x09,
'\u002A' => 0x0A,
'\u002B' => 0x0B,
'\u002C' => 0x0C,
'\u002D' => 0x0D,
'\u002E' => 0x0E,
'\u002F' => 0x0F,
'\u0030' => 0x10,
'\u0031' => 0x11,
'\u0032' => 0x12,
'\u0033' => 0x13,
'\u0034' => 0x14,
'\u0035' => 0x15,
'\u0036' => 0x16,
'\u0037' => 0x17,
'\u0038' => 0x18,
'\u0039' => 0x19,
'\u003A' => 0x1A,
'\u003B' => 0x1B,
'\u003C' => 0x1C,
'\u003D' => 0x1D,
'\u003E' => 0x1E,
'\u003F' => 0x1F,
'\u0040' => 0x20,
'\u0061' => 0x21,
'\u0062' => 0x22,
'\u0063' => 0x23,
'\u0064' => 0x24,
'\u0065' => 0x25,
'\u0066' => 0x26,
'\u0067' => 0x27,
'\u0068' => 0x28,
'\u0069' => 0x29,
'\u006A' => 0x2A,
'\u006B' => 0x2B,
'\u006C' => 0x2C,
'\u006D' => 0x2D,
'\u006E' => 0x2E,
'\u006F' => 0x2F,
'\u0070' => 0x30,
'\u0071' => 0x31,
'\u0072' => 0x32,
'\u0073' => 0x33,
'\u0074' => 0x34,
'\u0075' => 0x35,
'\u0076' => 0x36,
'\u0077' => 0x37,
'\u0078' => 0x38,
'\u0079' => 0x39,
'\u007A' => 0x3A,
'\u005B' => 0x3B,
'\u005C' => 0x3C,
'\u005D' => 0x3D,
'\u005E' => 0x3E,
'\u005F' => 0x3F,
'\u00A0' => 0x40,
'\u2575' => 0x41,
'\u2574' => 0x42,
'\u2577' => 0x43,
'\u2576' => 0x44,
'\u2518' => 0x45,
'\u2510' => 0x46,
'\u250C' => 0x47,
'\u2514' => 0x48,
'\u2500' => 0x49,
'\u2502' => 0x4A,
'\u2534' => 0x4B,
'\u2524' => 0x4C,
'\u252C' => 0x4D,
'\u251C' => 0x4E,
'\u253C' => 0x4F,
'\u25E4' => 0x50,
'\u25E5' => 0x51,
'\u2592' => 0x52,
'\u2598' => 0x53,
'\u259D' => 0x54,
'\u2580' => 0x55,
'\u2596' => 0x56,
'\u2597' => 0x57,
'\u259A' => 0x58,
'\u258C' => 0x59,
'\u2190' => 0x5C,
'\u2191' => 0x5D,
'\u2192' => 0x5E,
'\u2193' => 0x5F,
'\u03C0' => 0x60,
'\u0041' => 0x61,
'\u0042' => 0x62,
'\u0043' => 0x63,
'\u0044' => 0x64,
'\u0045' => 0x65,
'\u0046' => 0x66,
'\u0047' => 0x67,
'\u0048' => 0x68,
'\u0049' => 0x69,
'\u004A' => 0x6A,
'\u004B' => 0x6B,
'\u004C' => 0x6C,
'\u004D' => 0x6D,
'\u004E' => 0x6E,
'\u004F' => 0x6F,
'\u0050' => 0x70,
'\u0051' => 0x71,
'\u0052' => 0x72,
'\u0053' => 0x73,
'\u0054' => 0x74,
'\u0055' => 0x75,
'\u0056' => 0x76,
'\u0057' => 0x77,
'\u0058' => 0x78,
'\u0059' => 0x79,
'\u005A' => 0x7A,
'\u007B' => 0x7B,
'\u007C' => 0x7C,
'\u007D' => 0x7D,
'\u007E' => 0x7E,
_ => 0x3F
};
}

View File

@@ -0,0 +1,324 @@
//
// Apple IIgs.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents an Apple IIgs character encoding of Unicode characters.</summary>
public class Apple2gs : SingleByteEncodingWithRunes
{
/// <inheritdoc />
public override string BodyName => "apple2gs";
/// <inheritdoc />
public override int CodePage => 0;
/// <inheritdoc />
public override string EncodingName => "Western European (Apple IIgs)";
/// <inheritdoc />
public override string HeaderName => "apple2gs";
/// <inheritdoc />
public override string WebName => "";
/// <inheritdoc />
public override int WindowsCodePage => 0;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => true;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The Apple IIgs to Unicode character map. Inverted screen characters are mapped to normal characters.</summary>
protected override Rune[] CharTable => new[]
{
// 0x00
new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045),
new Rune(0x0046), new Rune(0x0047),
// 0x08
new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D),
new Rune(0x004E), new Rune(0x004F),
// 0x10
new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055),
new Rune(0x0056), new Rune(0x0057),
// 0x18
new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x005C), new Rune(0x005D),
new Rune(0x005E), new Rune(0x0020),
// 0x20
new Rune(0x2588), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025),
new Rune(0x0026), new Rune(0x0027),
// 0x28
new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D),
new Rune(0x002E), new Rune(0x002F),
// 0x30
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x38
new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D),
new Rune(0x003E), new Rune(0x003F),
// 0x40
new Rune(0xF8FF), new Rune(0x0000), new Rune(0x1FBB0), new Rune(0x231B), new Rune(0x2713), new Rune(0x1FBB1),
new Rune(0x1FBB4), new Rune(0x1FB81),
// 0x48
new Rune(0x2190), new Rune(0x2026), new Rune(0x2193), new Rune(0x2191), new Rune(0x2594), new Rune(0x21B5),
new Rune(0x2589), new Rune(0x1FBB5),
// 0x50
new Rune(0x1FBB6), new Rune(0x1FBB7), new Rune(0x1FBB8), new Rune(0x2500), new Rune(0x1FB7C), new Rune(0x2192),
new Rune(0x2592), new Rune(0x1FB90),
// 0x58
new Rune(0x1FBB9), new Rune(0x1FBBA), new Rune(0x2595), new Rune(0x25C6), new Rune(0x1FB80), new Rune(0x1FBBB),
new Rune(0x1FBBC), new Rune(0x258F),
// 0x60
new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065),
new Rune(0x0066), new Rune(0x0067),
// 0x68
new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D),
new Rune(0x006E), new Rune(0x006F),
// 0x70
new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075),
new Rune(0x0076), new Rune(0x0077),
// 0x78
new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D),
new Rune(0x007E), new Rune(0x0000),
// 0x80
new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045),
new Rune(0x0046), new Rune(0x0047),
// 0x88
new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D),
new Rune(0x004E), new Rune(0x004F),
// 0x90
new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055),
new Rune(0x0056), new Rune(0x0057),
// 0x98
new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x005C), new Rune(0x005D),
new Rune(0x005E), new Rune(0x005F),
// 0xA0
new Rune(0x0020), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025),
new Rune(0x0026), new Rune(0x0027),
// 0xA8
new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D),
new Rune(0x002E), new Rune(0x002F),
// 0xB0
new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035),
new Rune(0x0036), new Rune(0x0037),
// 0xB8
new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D),
new Rune(0x003E), new Rune(0x003F),
// 0xC0
new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045),
new Rune(0x0046), new Rune(0x0047),
// 0xC8
new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D),
new Rune(0x004E), new Rune(0x004F),
// 0xD0
new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055),
new Rune(0x0056), new Rune(0x0057),
// 0xD8
new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x005C), new Rune(0x005D),
new Rune(0x005E), new Rune(0x005F),
// 0xE0
new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065),
new Rune(0x0066), new Rune(0x0067),
// 0xE8
new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D),
new Rune(0x006E), new Rune(0x006F),
// 0xF0
new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075),
new Rune(0x0076), new Rune(0x0077),
// 0xF8
new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D),
new Rune(0x007E), new Rune(0x0000)
};
/// <summary>Converts a Unicode character to an Apple IIgs character</summary>
/// <returns>Apple IIgs character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(Rune character) => character.Value switch
{
0x2588 => 0x20,
0xF8FF => 0x40,
0x1FBB0 => 0x42,
0x231B => 0x43,
0x2713 => 0x44,
0x1FBB1 => 0x45,
0x1FBB4 => 0x46,
0x1FB81 => 0x47,
0x2190 => 0x48,
0x2026 => 0x49,
0x2193 => 0x4A,
0x2191 => 0x4B,
0x2594 => 0x4C,
0x21B5 => 0x4D,
0x2589 => 0x4E,
0x1FBB5 => 0x4F,
0x1FBB6 => 0x50,
0x1FBB7 => 0x51,
0x1FBB8 => 0x52,
0x2500 => 0x53,
0x1FB7C => 0x54,
0x2192 => 0x55,
0x2592 => 0x56,
0x1FB90 => 0x57,
0x1FBB9 => 0x58,
0x1FBBA => 0x59,
0x2595 => 0x5A,
0x25C6 => 0x5B,
0x1FB80 => 0x5C,
0x1FBBB => 0x5D,
0x1FBBC => 0x5E,
0x258F => 0x5F,
0x0040 => 0x80,
0x0041 => 0x81,
0x0042 => 0x82,
0x0043 => 0x83,
0x0044 => 0x84,
0x0045 => 0x85,
0x0046 => 0x86,
0x0047 => 0x87,
0x0048 => 0x88,
0x0049 => 0x89,
0x004A => 0x8A,
0x004B => 0x8B,
0x004C => 0x8C,
0x004D => 0x8D,
0x004E => 0x8E,
0x004F => 0x8F,
0x0050 => 0x90,
0x0051 => 0x91,
0x0052 => 0x92,
0x0053 => 0x93,
0x0054 => 0x94,
0x0055 => 0x95,
0x0056 => 0x96,
0x0057 => 0x97,
0x0058 => 0x98,
0x0059 => 0x99,
0x005A => 0x9A,
0x005B => 0x9B,
0x005C => 0x9C,
0x005D => 0x9D,
0x005E => 0x9E,
0x005F => 0x9F,
0x0020 => 0xA0,
0x0021 => 0xA1,
0x0022 => 0xA2,
0x0023 => 0xA3,
0x0024 => 0xA4,
0x2025 => 0xA5,
0x0026 => 0xA6,
0x0027 => 0xA7,
0x0028 => 0xA8,
0x0029 => 0xA9,
0x002A => 0xAA,
0x002B => 0xAB,
0x002C => 0xAC,
0x002D => 0xAD,
0x002E => 0xAE,
0x002F => 0xAF,
0x0030 => 0xB0,
0x0031 => 0xB1,
0x0032 => 0xB2,
0x0033 => 0xB3,
0x0034 => 0xB4,
0x0035 => 0xB5,
0x0036 => 0xB6,
0x0037 => 0xB7,
0x0038 => 0xB8,
0x0039 => 0xB9,
0x003A => 0xBA,
0x003B => 0xBB,
0x003C => 0xBC,
0x003D => 0xBD,
0x003E => 0xBE,
0x003F => 0xBF,
0x0060 => 0xE0,
0x0061 => 0xE1,
0x0062 => 0xE2,
0x0063 => 0xE3,
0x0064 => 0xE4,
0x0065 => 0xE5,
0x0066 => 0xE6,
0x0067 => 0xE7,
0x0068 => 0xE8,
0x0069 => 0xE9,
0x006A => 0xEA,
0x006B => 0xEB,
0x006C => 0xEC,
0x006D => 0xED,
0x006E => 0xEE,
0x006F => 0xEF,
0x0070 => 0xF0,
0x0071 => 0xF1,
0x0072 => 0xF2,
0x0073 => 0xF3,
0x0074 => 0xF4,
0x0075 => 0xF5,
0x0076 => 0xF6,
0x0077 => 0xF7,
0x0078 => 0xF8,
0x0079 => 0xF9,
0x007A => 0xFA,
0x007B => 0xFB,
0x007C => 0xFC,
0x007D => 0xFD,
0x007E => 0xFE,
_ => 0xBF
};
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,89 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NuGet.Build.Packaging.0.1.248\build\NuGet.Build.Packaging.props" Condition="Exists('..\packages\NuGet.Build.Packaging.0.1.248\build\NuGet.Build.Packaging.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{85DA90BC-9F49-4579-B4D1-4FF2D5925D7F}</ProjectGuid>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<UseMSBuildEngine>true</UseMSBuildEngine>
<OutputType>Library</OutputType>
<RootNamespace>Claunia.Encoding</RootNamespace>
<AssemblyName>Claunia.Encoding</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile78</TargetFrameworkProfile>
<PackOnBuild>true</PackOnBuild>
<PackageId>Claunia.Encoding</PackageId>
<PackageVersion>1.0</PackageVersion>
<Authors>Natalia Portillo</Authors>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Owners>Natalia Portillo</Owners>
<PackageProjectUrl>https://github.com/claunia/Claunia.Encoding</PackageProjectUrl>
<Summary>Library to provide codepage conversion to and from archaic and old computer systems and Unicode.</Summary>
<Title>Claunia.Encoding</Title>
<Description>Library to provide codepage conversion to and from archaic and old computer systems and Unicode.</Description>
<PackageLicenseUrl>https://raw.githubusercontent.com/claunia/Claunia.Encoding/master/LICENSE.MIT</PackageLicenseUrl>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Claunia.Encoding.xml</DocumentationFile>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Claunia.Encoding.xml</DocumentationFile>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Compile Include="PETSCII.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="LisaRoman.cs" />
<Compile Include="Encoding.cs" />
<Compile Include="Pangrams.cs" />
<Compile Include="ATASCII.cs" />
<Compile Include="AtariST.cs" />
<Compile Include="ZX80.cs" />
<Compile Include="ZX81.cs" />
<Compile Include="ZXSpectrum.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\LICENSE.MIT">
<Link>LICENSE.MIT</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="..\README.md">
<Link>README.md</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<ProjectExtensions>
<MonoDevelop>
<Properties>
<Policies>
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-csharp">
<inheritsSet />
<inheritsScope />
</TextStylePolicy>
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLineForMembersInObjectInit="False" NewLineForMembersInAnonymousTypes="False" NewLineForClausesInQuery="False" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceAfterControlFlowStatementKeyword="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" PlaceSystemDirectiveFirst="True" NewLinesForBracesInProperties="False" NewLinesForBracesInAccessors="False" NewLinesForBracesInAnonymousMethods="False" NewLinesForBracesInControlBlocks="False" NewLinesForBracesInAnonymousTypes="False" NewLinesForBracesInObjectCollectionArrayInitializers="False" NewLinesForBracesInLambdaExpressionBody="False" NewLineForElse="False" NewLineForCatch="False" NewLineForFinally="False" scope="text/x-csharp">
<inheritsSet />
<inheritsScope />
</CSharpFormattingPolicy>
</Policies>
</Properties>
</MonoDevelop>
</ProjectExtensions>
<Import Project="..\packages\NuGet.Build.Packaging.0.1.248\build\NuGet.Build.Packaging.targets" Condition="Exists('..\packages\NuGet.Build.Packaging.0.1.248\build\NuGet.Build.Packaging.targets')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{85DA90BC-9F49-4579-B4D1-4FF2D5925D7F}</ProjectGuid>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>Claunia.Encoding</RootNamespace>
<AssemblyName>Claunia.Encoding</AssemblyName>
<PackOnBuild>true</PackOnBuild>
<PackageId>Claunia.Encoding</PackageId>
<PackageVersion>1.9.2</PackageVersion>
<Authors>Natalia Portillo</Authors>
<Owners>Natalia Portillo</Owners>
<PackageProjectUrl>https://github.com/claunia/Claunia.Encoding</PackageProjectUrl>
<Summary>Library to provide codepage conversion to and from archaic and old computer systems and Unicode.</Summary>
<Title>Claunia.Encoding</Title>
<Description>Library to provide codepage conversion to and from archaic and old computer systems and Unicode.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<ReleaseVersion>1.9.2</ReleaseVersion>
<PackageReleaseNotes>Update to .NET 6.</PackageReleaseNotes>
<VersionPrefix>1.9.2</VersionPrefix>
<Company>Claunia.com</Company>
<Copyright>© 2016-2021 Natalia Portillo</Copyright>
<PackageProjectUrl>https://www.github.com/claunia/Claunia.Encoding</PackageProjectUrl>
<RepositoryType>git</RepositoryType>
<NeutralLanguage>en-US</NeutralLanguage>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<LangVersion>latest</LangVersion>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>TRACE;RELEASE</DefineConstants>
<DocumentationFile>bin\Release\Claunia.Encoding.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('netcoreapp')) Or $(TargetFramework.StartsWith('netstandard'))">
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="..\LICENSE.MIT">
<Link>LICENSE.MIT</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="..\README.md">
<Link>README.md</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@@ -4,7 +4,7 @@
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright (c) 2016 © Claunia.com
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -24,29 +24,101 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding
{
/// <summary>
/// This class contains static instances of the supported encodings.
/// </summary>
public static class Encoding
{
/// <summary>
/// Static instance for the LisaRoman encoding
/// </summary>
public static System.Text.Encoding LisaEncoding = new LisaRoman();
/// <summary>
/// Static instance for the ATASCII encoding
/// </summary>
public static System.Text.Encoding AtariEncoding = new ATASCII();
/// <summary>
/// Static instance for the Atari ST encoding
/// </summary>
public static System.Text.Encoding AtariSTEncoding = new AtariST();
/// <summary>
/// Static instance for the PETSCII encoding
/// </summary>
public static System.Text.Encoding PETEncoding = new PETSCII();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Claunia.Encoding;
/// <summary>This class contains static instances of the supported encodings.</summary>
public abstract class Encoding : System.Text.Encoding
{
/// <summary>Static instance for the LisaRoman encoding</summary>
public static System.Text.Encoding LisaEncoding = new LisaRoman();
/// <summary>Static instance for the ATASCII encoding</summary>
public static System.Text.Encoding AtariEncoding = new ATASCII();
/// <summary>Static instance for the Atari ST encoding</summary>
public static System.Text.Encoding AtariStEncoding = new AtariST();
/// <summary>Static instance for the PETSCII encoding</summary>
public static System.Text.Encoding PetEncoding = new PETSCII();
/// <summary>Static instance for the DEC Radix-50 encoding</summary>
public static System.Text.Encoding Radix50Encoding = new Radix50();
/// <summary>Static instance for the GEM encoding</summary>
public static System.Text.Encoding GemEncoding = new GEM();
/// <summary>Static instance for the GEM encoding</summary>
public static System.Text.Encoding GeosEncoding = new GEOS();
/// <summary>Gets a value indicating whether the current encoding can be used by browser clients for displaying content.</summary>
public abstract override bool IsBrowserDisplay { get; }
/// <summary>Gets a value indicating whether the current encoding can be used by browser clients for saving content.</summary>
public abstract override bool IsBrowserSave { get; }
/// <summary>
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
/// content.
/// </summary>
public abstract override bool IsMailNewsDisplay { get; }
/// <summary>Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.</summary>
public abstract override bool IsMailNewsSave { get; }
/// <summary>Gets a value indicating whether the current encoding is read-only.</summary>
/// <value>The is single byte.</value>
public new abstract bool IsReadOnly { get; }
/// <summary>Gets a value indicating whether the current encoding uses single-byte code points.</summary>
public abstract override bool IsSingleByte { get; }
/// <summary>Gets the code page identifier of the current Encoding.</summary>
public abstract override int CodePage { get; }
/// <summary>Gets a name for the current encoding that can be used with mail agent body tags</summary>
public abstract override string BodyName { get; }
/// <summary>Gets a name for the current encoding that can be used with mail agent header tags</summary>
public abstract override string HeaderName { get; }
/// <summary>Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.</summary>
public abstract override string WebName { get; }
/// <summary>Gets the human-readable description of the current encoding.</summary>
public abstract override string EncodingName { get; }
/// <summary>Gets the Windows operating system code page that most closely corresponds to the current encoding.</summary>
public abstract override int WindowsCodePage { get; }
/// <summary>Returns an array that contains all encodings.</summary>
/// <returns>An array that contains all encodings.</returns>
public new static IEnumerable<EncodingInfo> GetEncodings() =>
from type in Assembly.GetExecutingAssembly().GetTypes()
where type.IsSubclassOf(typeof(Encoding)) && !type.IsAbstract let encoding = (Encoding)type.
GetConstructor(new Type[]
{})?.Invoke(new object[]
{}) where encoding is {}
select new EncodingInfo(encoding.CodePage, encoding.BodyName, encoding.EncodingName, false, type);
/// <summary>Returns the encoding associated with the specified code page name.</summary>
/// <returns>The encoding associated with the specified code page.</returns>
/// <param name="name">
/// The code page name of the preferred encoding. Any value returned by the WebName property is valid.
/// Possible values are listed in the Name column of the table that appears in the Encoding class topic.
/// </param>
public new static System.Text.Encoding GetEncoding(string name)
{
foreach(Type type in Assembly.GetExecutingAssembly().GetTypes())
if(type.IsSubclassOf(typeof(Encoding)) &&
!type.IsAbstract)
{
var encoding = (Encoding)type.GetConstructor(new Type[]
{})?.Invoke(new object[]
{});
if(encoding?.BodyName == name.ToLowerInvariant())
return encoding;
}
return System.Text.Encoding.GetEncoding(name);
}
}

View File

@@ -0,0 +1,56 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace Claunia.Encoding;
/// <summary>Provides basic information about an encoding.</summary>
public sealed class EncodingInfo
{
readonly Type _thisType;
bool _isSystem;
internal EncodingInfo(int codePage, string name, string displayName, bool system = true, Type internalType = null)
{
CodePage = codePage;
Name = name;
DisplayName = displayName;
_isSystem = system;
_thisType = internalType;
}
/// <summary>Gets the code page identifier of the encoding.</summary>
/// <value>The code page identifier of the encoding.</value>
public int CodePage { get; }
/// <summary>Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the encoding.</summary>
/// <value>The IANA name for the encoding. For more information about the IANA, see www.iana.org.</value>
public string Name { get; }
/// <summary>Gets the human-readable description of the encoding.</summary>
/// <value>The human-readable description of the encoding.</value>
public string DisplayName { get; }
/// <summary>Returns a Encoding object that corresponds to the current EncodingInfo object.</summary>
/// <returns>
/// A <see cref="T:Claunia.Encoding.Encoding" /> object that corresponds to the current
/// <see cref="T:Claunia.Encoding.EncodingInfo" /> object.
/// </returns>
public Encoding GetEncoding() => (Encoding)_thisType.GetConstructor(new Type[]
{}).Invoke(new object[]
{});
/// <summary>Gets a value indicating whether the specified object is equal to the current EncodingInfo object.</summary>
/// <param name="value">An object to compare to the current <see cref="T:Claunia.Encoding.EncodingInfo" /> object.</param>
/// <returns>
/// <c>true</c> if value is a <see cref="T:Claunia.Encoding.EncodingInfo" /> and is equal to the current
/// <see cref="T:Claunia.Encoding.EncodingInfo" />; otherwise, <c>false</c>.
/// </returns>
public override bool Equals(object value) => value is EncodingInfo that && CodePage == that.CodePage;
/// <summary>Returns the hash code for the current EncodingInfo object.</summary>
/// <returns>A 32-bit signed integer hash code.</returns>
public override int GetHashCode() => CodePage;
}

445
Claunia.Encoding/GEM.cs Normal file
View File

@@ -0,0 +1,445 @@
//
// Gem.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents a GEM character encoding of Unicode characters.</summary>
public class GEM : SingleByteEncodingWithRunes
{
/// <inheritdoc />
public override string BodyName => "gem";
/// <inheritdoc />
public override int CodePage => 0;
/// <inheritdoc />
public override string EncodingName => "Western European (GEM)";
/// <inheritdoc />
public override string HeaderName => "gem";
/// <inheritdoc />
public override string WebName => "";
/// <inheritdoc />
public override int WindowsCodePage => 0;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => false;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The GEM to Unicode character map.</summary>
protected override Rune[] CharTable => new[]
{
// 0x00
new Rune(0x0000), new Rune(0x21E7), new Rune(0x21E9), new Rune(0x21E8), new Rune(0x21E6), new Rune(0x25FC),
new Rune(0x1F5D7), new Rune(0x25C6),
// 0x08
new Rune(0x2713), new Rune(0x1F552), new Rune(0x1F514), new Rune(0x266A), new Rune(0x25B4), new Rune(0x25BE),
new Rune(0x25B8), new Rune(0x25C2),
// 0x10
new Rune(0x25BA), new Rune(0x25C4), new Rune(0x29D3), new Rune(0x2582), new Rune(0x00B6), new Rune(0x00A7),
new Rune(0x2195), new Rune(0x21A8),
// 0x18
new Rune(0x2191), new Rune(0x2193), new Rune(0x2192), new Rune(0x2190), new Rune(0x221F), new Rune(0x2194),
new Rune(0x25B2), new Rune(0x25BC),
// 0x20
new Rune(0x0020), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025),
new Rune(0x0026), new Rune(0x0027),
// 0x28
new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D),
new Rune(0x002E), new Rune(0x002F),
// 0x30
new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035),
new Rune(0x0036), new Rune(0x0037),
// 0x38
new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D),
new Rune(0x003E), new Rune(0x003F),
// 0x40
new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045),
new Rune(0x0046), new Rune(0x0047),
// 0x48
new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D),
new Rune(0x004E), new Rune(0x004F),
// 0x50
new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055),
new Rune(0x0056), new Rune(0x0057),
// 0x58
new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x005C), new Rune(0x005D),
new Rune(0x005E), new Rune(0x005F),
// 0x60
new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065),
new Rune(0x0066), new Rune(0x0067),
// 0x68
new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D),
new Rune(0x006E), new Rune(0x006F),
// 0x70
new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075),
new Rune(0x0076), new Rune(0x0077),
// 0x78
new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D),
new Rune(0x007E), new Rune(0x2302),
// 0x80
new Rune(0x00C7), new Rune(0x00FC), new Rune(0x00E9), new Rune(0x00E2), new Rune(0x00E4), new Rune(0x00E0),
new Rune(0x00E5), new Rune(0x00E7),
// 0x88
new Rune(0x00EA), new Rune(0x00EB), new Rune(0x00E8), new Rune(0x00EF), new Rune(0x00EE), new Rune(0x00EC),
new Rune(0x00C4), new Rune(0x00C5),
// 0x90
new Rune(0x00C9), new Rune(0x00E6), new Rune(0x00C6), new Rune(0x00F4), new Rune(0x00F6), new Rune(0x00F2),
new Rune(0x00FB), new Rune(0x00F9),
// 0x98
new Rune(0x00FF), new Rune(0x00D6), new Rune(0x00DC), new Rune(0x00FB), new Rune(0x00A3), new Rune(0x00D8),
new Rune(0x00A4), new Rune(0x0192),
// 0xA0
new Rune(0x00E1), new Rune(0x00ED), new Rune(0x00F3), new Rune(0x00FA), new Rune(0x00F1), new Rune(0x00D1),
new Rune(0x00AA), new Rune(0x00BA),
// 0xA8
new Rune(0x00BF), new Rune(0x201C), new Rune(0x201D), new Rune(0x2039), new Rune(0x203A), new Rune(0x00A1),
new Rune(0x00AB), new Rune(0x00BB),
// 0xB0
new Rune(0x00E3), new Rune(0x00F5), new Rune(0x00A5), new Rune(0x00A2), new Rune(0x0153), new Rune(0x0152),
new Rune(0x00C0), new Rune(0x00C3),
// 0xB8
new Rune(0x00D5), new Rune(0x00A7), new Rune(0x2021), new Rune(0x2020), new Rune(0x00B6), new Rune(0x00A9),
new Rune(0x00AE), new Rune(0x2122),
// 0xC0
new Rune(0x201E), new Rune(0x2026), new Rune(0x2030), new Rune(0x2022), new Rune(0x2013), new Rune(0x2014),
new Rune(0x2070), new Rune(0x00C1),
// 0xC8
new Rune(0x00C2), new Rune(0x00C8), new Rune(0x00CA), new Rune(0x00CB), new Rune(0x00CC), new Rune(0x00CD),
new Rune(0x00CE), new Rune(0x00CF),
// 0xD0
new Rune(0x00D2), new Rune(0x00D3), new Rune(0x00D4), new Rune(0x0160), new Rune(0x0161), new Rune(0x00D9),
new Rune(0x00DA), new Rune(0x00DB),
// 0xD8
new Rune(0x0178), new Rune(0x00DF), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD),
new Rune(0xFFFD), new Rune(0xFFFD),
// 0xE0
new Rune(0x03B1), new Rune(0x03B2), new Rune(0x0393), new Rune(0x03C0), new Rune(0x03A3), new Rune(0x03C3),
new Rune(0x00B5), new Rune(0x03C4),
// 0xE8
new Rune(0x03A6), new Rune(0x0398), new Rune(0x03A9), new Rune(0x03B4), new Rune(0x222E), new Rune(0x0278),
new Rune(0x2208), new Rune(0x2229),
// 0xF0
new Rune(0x2261), new Rune(0x00B1), new Rune(0x2265), new Rune(0x2264), new Rune(0x2320), new Rune(0x2321),
new Rune(0x00F7), new Rune(0x2248),
// 0xF8
new Rune(0x00B0), new Rune(0x2219), new Rune(0x00B7), new Rune(0x221A), new Rune(0x207F), new Rune(0x00B2),
new Rune(0x25A0), new Rune(0x2205)
};
/// <summary>Converts a Unicode character to an GEM character</summary>
/// <returns>GEM character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(Rune character) => character.Value switch
{
0x0000 => 0x00,
0x21E7 => 0x01,
0x21E9 => 0x02,
0x21E8 => 0x03,
0x21E6 => 0x04,
0x25FC => 0x05,
0x1F5D7 => 0x06,
0x25C6 => 0x07,
0x2713 => 0x08,
0x1F552 => 0x09,
0x1F514 => 0x0A,
0x266A => 0x0B,
0x25B4 => 0x0C,
0x25BE => 0x0D,
0x25B8 => 0x0E,
0x25C2 => 0x0F,
0x25BA => 0x10,
0x25C4 => 0x11,
0x29D3 => 0x12,
0x2582 => 0x13,
0x2195 => 0x16,
0x21A8 => 0x17,
0x2191 => 0x18,
0x2193 => 0x19,
0x2192 => 0x1A,
0x2190 => 0x1B,
0x221F => 0x1C,
0x2194 => 0x1D,
0x25B2 => 0x1E,
0x25BC => 0x1F,
0x0020 => 0x20,
0x0021 => 0x21,
0x0022 => 0x22,
0x0023 => 0x23,
0x0024 => 0x24,
0x0025 => 0x25,
0x0026 => 0x26,
0x0027 => 0x27,
0x0028 => 0x28,
0x0029 => 0x29,
0x002A => 0x2A,
0x002B => 0x2B,
0x002C => 0x2C,
0x002D => 0x2D,
0x002E => 0x2E,
0x002F => 0x2F,
0x0030 => 0x30,
0x0031 => 0x31,
0x0032 => 0x32,
0x0033 => 0x33,
0x0034 => 0x34,
0x0035 => 0x35,
0x0036 => 0x36,
0x0037 => 0x37,
0x0038 => 0x38,
0x0039 => 0x39,
0x003A => 0x3A,
0x003B => 0x3B,
0x003C => 0x3C,
0x003D => 0x3D,
0x003E => 0x3E,
0x003F => 0x3F,
0x0040 => 0x40,
0x0041 => 0x41,
0x0042 => 0x42,
0x0043 => 0x43,
0x0044 => 0x44,
0x0045 => 0x45,
0x0046 => 0x46,
0x0047 => 0x47,
0x0048 => 0x48,
0x0049 => 0x49,
0x004A => 0x4A,
0x004B => 0x4B,
0x004C => 0x4C,
0x004D => 0x4D,
0x004E => 0x4E,
0x004F => 0x4F,
0x0050 => 0x50,
0x0051 => 0x51,
0x0052 => 0x52,
0x0053 => 0x53,
0x0054 => 0x54,
0x0055 => 0x55,
0x0056 => 0x56,
0x0057 => 0x57,
0x0058 => 0x58,
0x0059 => 0x59,
0x005A => 0x5A,
0x005B => 0x5B,
0x005C => 0x5C,
0x005D => 0x5D,
0x005E => 0x5E,
0x005F => 0x5F,
0x0060 => 0x60,
0x0061 => 0x61,
0x0062 => 0x62,
0x0063 => 0x63,
0x0064 => 0x64,
0x0065 => 0x65,
0x0066 => 0x66,
0x0067 => 0x67,
0x0068 => 0x68,
0x0069 => 0x69,
0x006A => 0x6A,
0x006B => 0x6B,
0x006C => 0x6C,
0x006D => 0x6D,
0x006E => 0x6E,
0x006F => 0x6F,
0x0070 => 0x70,
0x0071 => 0x71,
0x0072 => 0x72,
0x0073 => 0x73,
0x0074 => 0x74,
0x0075 => 0x75,
0x0076 => 0x76,
0x0077 => 0x77,
0x0078 => 0x78,
0x0079 => 0x79,
0x007A => 0x7A,
0x007B => 0x7B,
0x007C => 0x7C,
0x007D => 0x7D,
0x007E => 0x7E,
0x2302 => 0x7F,
0x00C7 => 0x80,
0x00FC => 0x81,
0x00E9 => 0x82,
0x00E2 => 0x83,
0x00E4 => 0x84,
0x00E0 => 0x85,
0x00E5 => 0x86,
0x00E7 => 0x87,
0x00EA => 0x88,
0x00EB => 0x89,
0x00E8 => 0x8A,
0x00EF => 0x8B,
0x00EE => 0x8C,
0x00EC => 0x8D,
0x00C4 => 0x8E,
0x00C5 => 0x8F,
0x00C9 => 0x90,
0x00E6 => 0x91,
0x00C6 => 0x92,
0x00F4 => 0x93,
0x00F6 => 0x94,
0x00F2 => 0x95,
0x00FB => 0x96,
0x00F9 => 0x97,
0x00FF => 0x98,
0x00D6 => 0x99,
0x00DC => 0x9A,
0x00F8 => 0x9B,
0x00A3 => 0x9C,
0x00D8 => 0x9D,
0x00A4 => 0x9E,
0x0192 => 0x9F,
0x00E1 => 0xA0,
0x00ED => 0xA1,
0x00F3 => 0xA2,
0x00FA => 0xA3,
0x00F1 => 0xA4,
0x00D1 => 0xA5,
0x00AA => 0xA6,
0x00BA => 0xA7,
0x00BF => 0xA8,
0x201C => 0xA9,
0x201D => 0xAA,
0x2039 => 0xAB,
0x203A => 0xAC,
0x00A1 => 0xAD,
0x00AB => 0xAE,
0x00BB => 0xAF,
0x00E3 => 0xB0,
0x00F5 => 0xB1,
0x00A5 => 0xB2,
0x00A2 => 0xB3,
0x0153 => 0xB4,
0x0152 => 0xB5,
0x00C0 => 0xB6,
0x00C3 => 0xB7,
0x00D5 => 0xB8,
0x00A7 => 0xB9,
0x2821 => 0xBA,
0x2020 => 0xBB,
0x00B6 => 0xBC,
0x00A9 => 0xBD,
0x00AE => 0xBE,
0x2122 => 0xBF,
0x201E => 0xC0,
0x2026 => 0xC1,
0x2030 => 0xC2,
0x2022 => 0xC3,
0x2013 => 0xC4,
0x2014 => 0xC5,
0x2070 => 0xC6,
0x00C1 => 0xC7,
0x00C2 => 0xC8,
0x00C8 => 0xC9,
0x00CA => 0xCA,
0x00CB => 0xCB,
0x00CC => 0xCC,
0x00CD => 0xCD,
0x00CE => 0xCE,
0x00CF => 0xCF,
0x00D2 => 0xD0,
0x00D3 => 0xD1,
0x00D4 => 0xD2,
0x0160 => 0xD3,
0x0161 => 0xD4,
0x00D9 => 0xD5,
0x00DA => 0xD6,
0x00DB => 0xD7,
0x0178 => 0xD8,
0x00DF => 0xD9,
0x03B1 => 0xE0,
0x03B2 => 0xE1,
0x0393 => 0xE2,
0x03C0 => 0xE3,
0x03A3 => 0xE4,
0x03C3 => 0xE5,
0x00B5 => 0xE6,
0x03C4 => 0xE7,
0x03A6 => 0xE8,
0x0398 => 0xE9,
0x03A9 => 0xEA,
0x03B4 => 0xEB,
0x222E => 0xEC,
0x0278 => 0xED,
0x2208 => 0xEE,
0x2229 => 0xEF,
0x2261 => 0xF0,
0x00B1 => 0xF1,
0x2265 => 0xF2,
0x2264 => 0xF3,
0x2320 => 0xF4,
0x2321 => 0xF5,
0x00F7 => 0xF6,
0x2248 => 0xF7,
0x00B0 => 0xF8,
0x2219 => 0xF9,
0x00B7 => 0xFA,
0x221A => 0xFB,
0x207F => 0xFC,
0x00B2 => 0xFD,
0x25A0 => 0xFE,
0x2205 => 0xFF,
_ => 0x3F
};
}

408
Claunia.Encoding/GEOS.cs Normal file
View File

@@ -0,0 +1,408 @@
//
// Geos.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents an GEOS character encoding of Unicode characters.</summary>
public class GEOS : SingleByteEncoding
{
/// <inheritdoc />
public override string BodyName => "geos";
/// <inheritdoc />
public override int CodePage => 0;
/// <inheritdoc />
public override string EncodingName => "Western European (GEOS)";
/// <inheritdoc />
public override string HeaderName => "geos";
/// <inheritdoc />
public override string WebName => "";
/// <inheritdoc />
public override int WindowsCodePage => 0;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => false;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>
/// The GEOS to Unicode character map. In the GEOS character map application lots of positions appears as '\u002E'
/// ('.' period) in normal (non-symbol) fonts.
/// </summary>
protected override char[] CharTable => new[]
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
// 0x10
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
// 0x80
'\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8',
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
// 0x98
'\u00F2', '\u00F4', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC', '\u2020',
// 0xA0
'\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u00B7', '\u00B6', '\u00DF', '\u00AE',
// 0xA8
'\u00A9', '\u2122', '\u0022', '\u0027', '\u002E', '\u00C6', '\u00D8', '\u221E',
// 0xB0
'\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u002E', '\u002E', '\u002E',
// 0xB8
'\u03C0', '\u002E', '\u00AA', '\u00BA', '\u03A9', '\u00E6', '\u00F8', '\u00BF',
// 0xC0
'\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u002E', '\u00AB', '\u00BB',
// 0xC8
'\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153', '\u2013',
// 0xD0
'\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u002E', '\u00FF',
// 0xD8
'\u0178', '\u002E', '\u00A4', '\u2039', '\u203A', '\u00FD', '\u00DD', '\u2021',
// 0xE0
'\u002E', '\u201A', '\u201E', '\u2030', '\u00C2', '\u00CA', '\u00C1', '\u00CB',
// 0xE8
'\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4', '\u002E',
// 0xF0
'\u00D2', '\u00DA', '\u00D9', '\u00B9', '\u20C6', '\u20DC', '\u00AF', '\u02C7',
// 0xF8
'\u00B7', '\u00B0', '\u00B8', '\u2032', '\u02DB', '\u02D8', '\u00A0', '\u002E'
};
/// <summary>Converts a Unicode character to an GEOS character</summary>
/// <returns>GEOS character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(char character) => character switch
{
'\u0000' => 0x00,
'\u0001' => 0x01,
'\u0002' => 0x02,
'\u0003' => 0x03,
'\u0004' => 0x04,
'\u0005' => 0x05,
'\u0006' => 0x06,
'\u0007' => 0x07,
'\u0008' => 0x08,
'\u0009' => 0x09,
'\u000A' => 0x0A,
'\u000B' => 0x0B,
'\u000C' => 0x0C,
'\u000D' => 0x0D,
'\u000E' => 0x0E,
'\u000F' => 0x0F,
'\u0010' => 0x10,
'\u0011' => 0x11,
'\u0012' => 0x12,
'\u0013' => 0x13,
'\u0014' => 0x14,
'\u0015' => 0x15,
'\u0016' => 0x16,
'\u0017' => 0x17,
'\u0018' => 0x18,
'\u0019' => 0x19,
'\u001A' => 0x1A,
'\u001B' => 0x1B,
'\u001C' => 0x1C,
'\u001D' => 0x1D,
'\u001E' => 0x1E,
'\u001F' => 0x1F,
'\u0020' => 0x20,
'\u0021' => 0x21,
'\u0022' => 0x22,
'\u0023' => 0x23,
'\u0024' => 0x24,
'\u0025' => 0x25,
'\u0026' => 0x26,
'\u0027' => 0x27,
'\u0028' => 0x28,
'\u0029' => 0x29,
'\u002A' => 0x2A,
'\u002B' => 0x2B,
'\u002C' => 0x2C,
'\u002D' => 0x2D,
'\u002E' => 0x2E,
'\u002F' => 0x2F,
'\u0030' => 0x30,
'\u0031' => 0x31,
'\u0032' => 0x32,
'\u0033' => 0x33,
'\u0034' => 0x34,
'\u0035' => 0x35,
'\u0036' => 0x36,
'\u0037' => 0x37,
'\u0038' => 0x38,
'\u0039' => 0x39,
'\u003A' => 0x3A,
'\u003B' => 0x3B,
'\u003C' => 0x3C,
'\u003D' => 0x3D,
'\u003E' => 0x3E,
'\u003F' => 0x3F,
'\u0040' => 0x40,
'\u0041' => 0x41,
'\u0042' => 0x42,
'\u0043' => 0x43,
'\u0044' => 0x44,
'\u0045' => 0x45,
'\u0046' => 0x46,
'\u0047' => 0x47,
'\u0048' => 0x48,
'\u0049' => 0x49,
'\u004A' => 0x4A,
'\u004B' => 0x4B,
'\u004C' => 0x4C,
'\u004D' => 0x4D,
'\u004E' => 0x4E,
'\u004F' => 0x4F,
'\u0050' => 0x50,
'\u0051' => 0x51,
'\u0052' => 0x52,
'\u0053' => 0x53,
'\u0054' => 0x54,
'\u0055' => 0x55,
'\u0056' => 0x56,
'\u0057' => 0x57,
'\u0058' => 0x58,
'\u0059' => 0x59,
'\u005A' => 0x5A,
'\u005B' => 0x5B,
'\u005C' => 0x5C,
'\u005D' => 0x5D,
'\u005E' => 0x5E,
'\u005F' => 0x5F,
'\u0060' => 0x60,
'\u0061' => 0x61,
'\u0062' => 0x62,
'\u0063' => 0x63,
'\u0064' => 0x64,
'\u0065' => 0x65,
'\u0066' => 0x66,
'\u0067' => 0x67,
'\u0068' => 0x68,
'\u0069' => 0x69,
'\u006A' => 0x6A,
'\u006B' => 0x6B,
'\u006C' => 0x6C,
'\u006D' => 0x6D,
'\u006E' => 0x6E,
'\u006F' => 0x6F,
'\u0070' => 0x70,
'\u0071' => 0x71,
'\u0072' => 0x72,
'\u0073' => 0x73,
'\u0074' => 0x74,
'\u0075' => 0x75,
'\u0076' => 0x76,
'\u0077' => 0x77,
'\u0078' => 0x78,
'\u0079' => 0x79,
'\u007A' => 0x7A,
'\u007B' => 0x7B,
'\u007C' => 0x7C,
'\u007D' => 0x7D,
'\u007E' => 0x7E,
'\u007F' => 0x7F,
'\u00C4' => 0x80,
'\u00C5' => 0x81,
'\u00C7' => 0x82,
'\u00C9' => 0x83,
'\u00D1' => 0x84,
'\u00D6' => 0x85,
'\u00DC' => 0x86,
'\u00E1' => 0x87,
'\u00E0' => 0x88,
'\u00E2' => 0x89,
'\u00E4' => 0x8A,
'\u00E3' => 0x8B,
'\u00E5' => 0x8C,
'\u00E7' => 0x8D,
'\u00E9' => 0x8E,
'\u00E8' => 0x8F,
'\u00EA' => 0x90,
'\u00EB' => 0x91,
'\u00ED' => 0x92,
'\u00EC' => 0x93,
'\u00EE' => 0x94,
'\u00EF' => 0x95,
'\u00F1' => 0x96,
'\u00F3' => 0x97,
'\u00F2' => 0x98,
'\u00F4' => 0x99,
'\u00F5' => 0x9A,
'\u00FA' => 0x9B,
'\u00F9' => 0x9C,
'\u00FB' => 0x9D,
'\u00FC' => 0x9E,
'\u2020' => 0x9F,
'\u00B0' => 0xA0,
'\u00A2' => 0xA1,
'\u00A3' => 0xA2,
'\u00A7' => 0xA3,
'\u00B7' => 0xA4,
'\u00B6' => 0xA5,
'\u00DF' => 0xA6,
'\u00AE' => 0xA7,
'\u00A9' => 0xA8,
'\u2122' => 0xA9,
'\u00C6' => 0xAD,
'\u00D8' => 0xAE,
'\u221E' => 0xAF,
'\u00B1' => 0xB0,
'\u2264' => 0xB1,
'\u2265' => 0xB2,
'\u00A5' => 0xB3,
'\u00B5' => 0xB4,
'\u03C0' => 0xB8,
'\u00AA' => 0xBA,
'\u00BA' => 0xBB,
'\u03A9' => 0xBC,
'\u00E6' => 0xBD,
'\u00F8' => 0xBE,
'\u00BF' => 0xBF,
'\u00A1' => 0xC0,
'\u00AC' => 0xC1,
'\u221A' => 0xC2,
'\u0192' => 0xC3,
'\u2248' => 0xC4,
'\u00AB' => 0xC6,
'\u00BB' => 0xC7,
'\u2026' => 0xC8,
'\u00A0' => 0xC9,
'\u00C0' => 0xCA,
'\u00C3' => 0xCB,
'\u00D5' => 0xCC,
'\u0152' => 0xCD,
'\u0153' => 0xCE,
'\u2013' => 0xCF,
'\u2014' => 0xD0,
'\u201C' => 0xD1,
'\u201D' => 0xD2,
'\u2018' => 0xD3,
'\u2019' => 0xD4,
'\u00F7' => 0xD5,
'\u00FF' => 0xD7,
'\u0178' => 0xD8,
'\u05A4' => 0xDA,
'\u2039' => 0xDB,
'\u203A' => 0xDC,
'\u00FD' => 0xDD,
'\u00DD' => 0xDE,
'\u2021' => 0xDF,
'\u201A' => 0xE1,
'\u201E' => 0xE2,
'\u2030' => 0xE3,
'\u00C2' => 0xE4,
'\u00CA' => 0xE5,
'\u00C1' => 0xE6,
'\u00CB' => 0xE7,
'\u00C8' => 0xE8,
'\u00CD' => 0xE9,
'\u00CE' => 0xEA,
'\u00CF' => 0xEB,
'\u00CC' => 0xEC,
'\u00D3' => 0xED,
'\u00D4' => 0xEE,
'\u00D2' => 0xF0,
'\u00DA' => 0xF1,
'\u00D9' => 0xF2,
'\u00B9' => 0xF3,
'\u20C6' => 0xF4,
'\u20DC' => 0xF5,
'\u00AF' => 0xF6,
'\u02C7' => 0xF7,
'\u00B8' => 0xFA,
'\u2032' => 0xFB,
'\u02DB' => 0xFC,
'\u02D8' => 0xFD,
_ => 0x3F
};
}

View File

@@ -0,0 +1 @@
global using System.Text;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,398 @@
//
// AtariST.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents an Mac Arabic character encoding of Unicode characters.</summary>
public class MacArabic : SingleByteEncoding
{
/// <inheritdoc />
public override string BodyName => "x-mac-arabic";
/// <inheritdoc />
public override int CodePage => 10004;
/// <inheritdoc />
public override string EncodingName => "Arabic (Mac)";
/// <inheritdoc />
public override string HeaderName => "x-mac-arabic";
/// <inheritdoc />
public override string WebName => "x-mac-arabic";
/// <inheritdoc />
public override int WindowsCodePage => 10004;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => true;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The Macintosh Arabic to Unicode character map.</summary>
protected override char[] CharTable => new[]
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
// 0x10
'\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017',
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
// 0x80
'\u00C4', '\u00A0', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u06BA', '\u00AB', '\u00E7', '\u00E9', '\u00E8',
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u2026', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
// 0x98
'\u00BB', '\u00F4', '\u00F6', '\u00F7', '\u00FA', '\u00F9', '\u00FB', '\u00FC',
// 0xA0
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u066A', '\u0026', '\u0027',
// 0xA8
'\u0028', '\u0029', '\u002A', '\u002B', '\u060C', '\u002D', '\u002E', '\u002F',
// 0xB0
'\u0660', '\u0661', '\u0662', '\u0663', '\u0664', '\u0665', '\u0666', '\u0667',
// 0xB8
'\u0668', '\u0669', '\u003A', '\u061B', '\u003C', '\u003D', '\u003E', '\u061F',
// 0xC0
'\u274A', '\u0621', '\u0622', '\u0623', '\u0624', '\u0625', '\u0626', '\u0627',
// 0xC8
'\u0628', '\u0629', '\u062A', '\u062B', '\u062C', '\u062D', '\u062E', '\u062F',
// 0xD0
'\u0630', '\u0631', '\u0632', '\u0633', '\u0634', '\u0635', '\u0636', '\u0637',
// 0xD8
'\u0638', '\u0639', '\u063A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0xE0
'\u0640', '\u0641', '\u0642', '\u0643', '\u0644', '\u0645', '\u0646', '\u0647',
// 0xE8
'\u0648', '\u0649', '\u064A', '\u064B', '\u064C', '\u064D', '\u064E', '\u064F',
// 0xF0
'\u0650', '\u0651', '\u0652', '\u067E', '\u0679', '\u0686', '\u06D5', '\u06A4',
// 0xF8
'\u06AF', '\u0688', '\u0691', '\u007B', '\u007C', '\u007D', '\u0698', '\u06D2'
};
/// <summary>Converts a Unicode character to an Mac Arabic character</summary>
/// <returns>Mac Arabic character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(char character) => character switch
{
'\u0000' => 0x00,
'\u0001' => 0x01,
'\u0002' => 0x02,
'\u0003' => 0x03,
'\u0004' => 0x04,
'\u0005' => 0x05,
'\u0006' => 0x06,
'\u0007' => 0x07,
'\u0008' => 0x08,
'\u0009' => 0x09,
'\u000A' => 0x0A,
'\u000B' => 0x0B,
'\u000C' => 0x0C,
'\u000D' => 0x0D,
'\u000E' => 0x0E,
'\u000F' => 0x0F,
'\u0010' => 0x10,
'\u2318' => 0x11,
'\u0012' => 0x12,
'\u2713' => 0x12,
'\u0013' => 0x13,
'\u25C6' => 0x13,
'\u0014' => 0x14,
'\uF8FF' => 0x14,
'\u0015' => 0x15,
'\u0016' => 0x16,
'\u0017' => 0x17,
'\u0018' => 0x18,
'\u0019' => 0x19,
'\u001A' => 0x1A,
'\u001B' => 0x1B,
'\u001C' => 0x1C,
'\u001D' => 0x1D,
'\u001E' => 0x1E,
'\u001F' => 0x1F,
'\u0020' => 0x20,
'\u0021' => 0x21,
'\u0022' => 0x22,
'\u0023' => 0x23,
'\u0024' => 0x24,
'\u0025' => 0x25,
'\u0026' => 0x26,
'\u0027' => 0x27,
'\u0028' => 0x28,
'\u0029' => 0x29,
'\u002A' => 0x2A,
'\u002B' => 0x2B,
'\u002C' => 0x2C,
'\u002D' => 0x2D,
'\u002E' => 0x2E,
'\u002F' => 0x2F,
'\u0030' => 0x30,
'\u0031' => 0x31,
'\u0032' => 0x32,
'\u0033' => 0x33,
'\u0034' => 0x34,
'\u0035' => 0x35,
'\u0036' => 0x36,
'\u0037' => 0x37,
'\u0038' => 0x38,
'\u0039' => 0x39,
'\u003A' => 0x3A,
'\u003B' => 0x3B,
'\u003C' => 0x3C,
'\u003D' => 0x3D,
'\u003E' => 0x3E,
'\u003F' => 0x3F,
'\u0040' => 0x40,
'\u0041' => 0x41,
'\u0042' => 0x42,
'\u0043' => 0x43,
'\u0044' => 0x44,
'\u0045' => 0x45,
'\u0046' => 0x46,
'\u0047' => 0x47,
'\u0048' => 0x48,
'\u0049' => 0x49,
'\u004A' => 0x4A,
'\u004B' => 0x4B,
'\u004C' => 0x4C,
'\u004D' => 0x4D,
'\u004E' => 0x4E,
'\u004F' => 0x4F,
'\u0050' => 0x50,
'\u0051' => 0x51,
'\u0052' => 0x52,
'\u0053' => 0x53,
'\u0054' => 0x54,
'\u0055' => 0x55,
'\u0056' => 0x56,
'\u0057' => 0x57,
'\u0058' => 0x58,
'\u0059' => 0x59,
'\u005A' => 0x5A,
'\u005B' => 0x5B,
'\u005C' => 0x5C,
'\u005D' => 0x5D,
'\u005E' => 0x5E,
'\u005F' => 0x5F,
'\u0060' => 0x60,
'\u0061' => 0x61,
'\u0062' => 0x62,
'\u0063' => 0x63,
'\u0064' => 0x64,
'\u0065' => 0x65,
'\u0066' => 0x66,
'\u0067' => 0x67,
'\u0068' => 0x68,
'\u0069' => 0x69,
'\u006A' => 0x6A,
'\u006B' => 0x6B,
'\u006C' => 0x6C,
'\u006D' => 0x6D,
'\u006E' => 0x6E,
'\u006F' => 0x6F,
'\u0070' => 0x70,
'\u0071' => 0x71,
'\u0072' => 0x72,
'\u0073' => 0x73,
'\u0074' => 0x74,
'\u0075' => 0x75,
'\u0076' => 0x76,
'\u0077' => 0x77,
'\u0078' => 0x78,
'\u0079' => 0x79,
'\u007A' => 0x7A,
'\u007B' => 0x7B,
'\u007C' => 0x7C,
'\u007D' => 0x7D,
'\u007E' => 0x7E,
'\u007F' => 0x7F,
'\u00C4' => 0x80,
'\u00A0' => 0x81,
'\u00C7' => 0x82,
'\u00C9' => 0x83,
'\u00D1' => 0x84,
'\u00D6' => 0x85,
'\u00DC' => 0x86,
'\u00E1' => 0x87,
'\u00E0' => 0x88,
'\u00E2' => 0x89,
'\u00E4' => 0x8A,
'\u06BA' => 0x8B,
'\u00AB' => 0x8C,
'\u00E7' => 0x8D,
'\u00E9' => 0x8E,
'\u00E8' => 0x8F,
'\u00EA' => 0x90,
'\u00EB' => 0x91,
'\u00ED' => 0x92,
'\u2026' => 0x93,
'\u00EE' => 0x94,
'\u00EF' => 0x95,
'\u00F1' => 0x96,
'\u00F3' => 0x97,
'\u00BB' => 0x98,
'\u00F4' => 0x99,
'\u00F6' => 0x9A,
'\u00F7' => 0x9B,
'\u00FA' => 0x9C,
'\u00F9' => 0x9D,
'\u00FB' => 0x9E,
'\u00FC' => 0x9F,
'\u066A' => 0xA5,
'\u060C' => 0xAC,
'\u0660' => 0xB0,
'\u0661' => 0xB1,
'\u0662' => 0xB2,
'\u0663' => 0xB3,
'\u0664' => 0xB4,
'\u0665' => 0xB5,
'\u0666' => 0xB6,
'\u0667' => 0xB7,
'\u0668' => 0xB8,
'\u0669' => 0xB9,
'\u061B' => 0xBB,
'\u061F' => 0xBF,
'\u274A' => 0xC0,
'\u0621' => 0xC1,
'\u0622' => 0xC2,
'\u0623' => 0xC3,
'\u0624' => 0xC4,
'\u0625' => 0xC5,
'\u0626' => 0xC6,
'\u0627' => 0xC7,
'\u0628' => 0xC8,
'\u0629' => 0xC9,
'\u062A' => 0xCA,
'\u062B' => 0xCB,
'\u062C' => 0xCC,
'\u062D' => 0xCD,
'\u062E' => 0xCE,
'\u062F' => 0xCF,
'\u0630' => 0xD0,
'\u0631' => 0xD1,
'\u0632' => 0xD2,
'\u0633' => 0xD3,
'\u0634' => 0xD4,
'\u0635' => 0xD5,
'\u0636' => 0xD6,
'\u0637' => 0xD7,
'\u0638' => 0xD8,
'\u0639' => 0xD9,
'\u063A' => 0xDA,
'\u0640' => 0xE0,
'\u0641' => 0xE1,
'\u0642' => 0xE2,
'\u0643' => 0xE3,
'\u0644' => 0xE4,
'\u0645' => 0xE5,
'\u0646' => 0xE6,
'\u0647' => 0xE7,
'\u0648' => 0xE8,
'\u0649' => 0xE9,
'\u064A' => 0xEA,
'\u064B' => 0xEB,
'\u064C' => 0xEC,
'\u064D' => 0xED,
'\u064E' => 0xEE,
'\u064F' => 0xEF,
'\u0650' => 0xF0,
'\u0651' => 0xF1,
'\u0652' => 0xF2,
'\u067E' => 0xF3,
'\u0679' => 0xF4,
'\u0686' => 0xF5,
'\u06D5' => 0xF6,
'\u06A4' => 0xF7,
'\u06AF' => 0xF8,
'\u0688' => 0xF9,
'\u0691' => 0xFA,
'\u0698' => 0xFE,
'\u06D2' => 0xFF,
_ => 0x3F
};
}

View File

@@ -0,0 +1,424 @@
//
// AtariST.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents an Mac CentralEuropean character encoding of Unicode characters.</summary>
public class MacCentralEuropean : SingleByteEncoding
{
/// <inheritdoc />
public override string BodyName => "x-mac-ce";
/// <inheritdoc />
public override int CodePage => 10029;
/// <inheritdoc />
public override string EncodingName => "Central European (Mac)";
/// <inheritdoc />
public override string HeaderName => "x-mac-ce";
/// <inheritdoc />
public override string WebName => "x-mac-ce";
/// <inheritdoc />
public override int WindowsCodePage => 10029;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => true;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The Macintosh CentralEuropean to Unicode character map.</summary>
protected override char[] CharTable => new[]
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
// 0x10
'\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017',
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
// 0x80
'\u00C4', '\u0100', '\u0101', '\u00C9', '\u0104', '\u00D6', '\u00DC', '\u00E1',
// 0x88
'\u0105', '\u010C', '\u00E4', '\u010D', '\u0106', '\u0107', '\u00E9', '\u0179',
// 0x90
'\u017A', '\u010E', '\u00ED', '\u010F', '\u0112', '\u0113', '\u0116', '\u00F3',
// 0x98
'\u0117', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u011A', '\u011B', '\u00FC',
// 0xA0
'\u2020', '\u00B0', '\u0118', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF',
// 0xA8
'\u00AE', '\u00A9', '\u2122', '\u0119', '\u00A8', '\u2260', '\u0123', '\u012E',
// 0xB0
'\u012F', '\u012A', '\u2264', '\u2265', '\u012B', '\u0136', '\u2202', '\u2211',
// 0xB8
'\u0142', '\u013B', '\u013C', '\u013D', '\u013E', '\u0139', '\u013A', '\u0145',
// 0xC0
'\u0146', '\u0143', '\u00AC', '\u221A', '\u0144', '\u0147', '\u2206', '\u00AB',
// 0xC8
'\u00BB', '\u2026', '\u00A0', '\u0148', '\u0150', '\u00D5', '\u0151', '\u014C',
// 0xD0
'\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA',
// 0xD8
'\u014D', '\u0154', '\u0155', '\u0158', '\u2039', '\u203A', '\u0159', '\u0156',
// 0xE0
'\u0157', '\u0160', '\u201A', '\u201E', '\u0161', '\u015A', '\u015B', '\u00C1',
// 0xE8
'\u0164', '\u0165', '\u00CD', '\u017D', '\u017E', '\u016A', '\u00D3', '\u00D4',
// 0xF0
'\u016B', '\u016E', '\u00DA', '\u016F', '\u0170', '\u0171', '\u0172', '\u0173',
// 0xF8
'\u00DD', '\u00FD', '\u0137', '\u017B', '\u0141', '\u017C', '\u0122', '\u02C7'
};
/// <summary>Converts a Unicode character to an Mac CentralEuropean character</summary>
/// <returns>Mac CentralEuropean character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(char character) => character switch
{
'\u0000' => 0x00,
'\u0001' => 0x01,
'\u0002' => 0x02,
'\u0003' => 0x03,
'\u0004' => 0x04,
'\u0005' => 0x05,
'\u0006' => 0x06,
'\u0007' => 0x07,
'\u0008' => 0x08,
'\u0009' => 0x09,
'\u000A' => 0x0A,
'\u000B' => 0x0B,
'\u000C' => 0x0C,
'\u000D' => 0x0D,
'\u000E' => 0x0E,
'\u000F' => 0x0F,
'\u0010' => 0x10,
'\u2318' => 0x11,
'\u0012' => 0x12,
'\u2713' => 0x12,
'\u0013' => 0x13,
'\u25C6' => 0x13,
'\u0014' => 0x14,
'\uF8FF' => 0x14,
'\u0015' => 0x15,
'\u0016' => 0x16,
'\u0017' => 0x17,
'\u0018' => 0x18,
'\u0019' => 0x19,
'\u001A' => 0x1A,
'\u001B' => 0x1B,
'\u001C' => 0x1C,
'\u001D' => 0x1D,
'\u001E' => 0x1E,
'\u001F' => 0x1F,
'\u0020' => 0x20,
'\u0021' => 0x21,
'\u0022' => 0x22,
'\u0023' => 0x23,
'\u0024' => 0x24,
'\u0025' => 0x25,
'\u0026' => 0x26,
'\u0027' => 0x27,
'\u0028' => 0x28,
'\u0029' => 0x29,
'\u002A' => 0x2A,
'\u002B' => 0x2B,
'\u002C' => 0x2C,
'\u002D' => 0x2D,
'\u002E' => 0x2E,
'\u002F' => 0x2F,
'\u0030' => 0x30,
'\u0031' => 0x31,
'\u0032' => 0x32,
'\u0033' => 0x33,
'\u0034' => 0x34,
'\u0035' => 0x35,
'\u0036' => 0x36,
'\u0037' => 0x37,
'\u0038' => 0x38,
'\u0039' => 0x39,
'\u003A' => 0x3A,
'\u003B' => 0x3B,
'\u003C' => 0x3C,
'\u003D' => 0x3D,
'\u003E' => 0x3E,
'\u003F' => 0x3F,
'\u0040' => 0x40,
'\u0041' => 0x41,
'\u0042' => 0x42,
'\u0043' => 0x43,
'\u0044' => 0x44,
'\u0045' => 0x45,
'\u0046' => 0x46,
'\u0047' => 0x47,
'\u0048' => 0x48,
'\u0049' => 0x49,
'\u004A' => 0x4A,
'\u004B' => 0x4B,
'\u004C' => 0x4C,
'\u004D' => 0x4D,
'\u004E' => 0x4E,
'\u004F' => 0x4F,
'\u0050' => 0x50,
'\u0051' => 0x51,
'\u0052' => 0x52,
'\u0053' => 0x53,
'\u0054' => 0x54,
'\u0055' => 0x55,
'\u0056' => 0x56,
'\u0057' => 0x57,
'\u0058' => 0x58,
'\u0059' => 0x59,
'\u005A' => 0x5A,
'\u005B' => 0x5B,
'\u005C' => 0x5C,
'\u005D' => 0x5D,
'\u005E' => 0x5E,
'\u005F' => 0x5F,
'\u0060' => 0x60,
'\u0061' => 0x61,
'\u0062' => 0x62,
'\u0063' => 0x63,
'\u0064' => 0x64,
'\u0065' => 0x65,
'\u0066' => 0x66,
'\u0067' => 0x67,
'\u0068' => 0x68,
'\u0069' => 0x69,
'\u006A' => 0x6A,
'\u006B' => 0x6B,
'\u006C' => 0x6C,
'\u006D' => 0x6D,
'\u006E' => 0x6E,
'\u006F' => 0x6F,
'\u0070' => 0x70,
'\u0071' => 0x71,
'\u0072' => 0x72,
'\u0073' => 0x73,
'\u0074' => 0x74,
'\u0075' => 0x75,
'\u0076' => 0x76,
'\u0077' => 0x77,
'\u0078' => 0x78,
'\u0079' => 0x79,
'\u007A' => 0x7A,
'\u007B' => 0x7B,
'\u007C' => 0x7C,
'\u007D' => 0x7D,
'\u007E' => 0x7E,
'\u007F' => 0x7F,
'\u00C4' => 0x80,
'\u0100' => 0x81,
'\u0101' => 0x82,
'\u00C9' => 0x83,
'\u0104' => 0x84,
'\u00D6' => 0x85,
'\u00DC' => 0x86,
'\u00E1' => 0x87,
'\u0105' => 0x88,
'\u010C' => 0x89,
'\u00E4' => 0x8A,
'\u010D' => 0x8B,
'\u0106' => 0x8C,
'\u0107' => 0x8D,
'\u00E9' => 0x8E,
'\u0179' => 0x8F,
'\u017A' => 0x90,
'\u010E' => 0x91,
'\u00ED' => 0x92,
'\u010F' => 0x93,
'\u0112' => 0x94,
'\u0113' => 0x95,
'\u0116' => 0x96,
'\u00F3' => 0x97,
'\u0117' => 0x98,
'\u00F4' => 0x99,
'\u00F6' => 0x9A,
'\u00F5' => 0x9B,
'\u00FA' => 0x9C,
'\u011A' => 0x9D,
'\u011B' => 0x9E,
'\u00FC' => 0x9F,
'\u2020' => 0xA0,
'\u00B0' => 0xA1,
'\u0118' => 0xA2,
'\u00A3' => 0xA3,
'\u00A7' => 0xA4,
'\u2022' => 0xA5,
'\u00B6' => 0xA6,
'\u00DF' => 0xA7,
'\u00AE' => 0xA8,
'\u00A9' => 0xA9,
'\u2122' => 0xAA,
'\u0119' => 0xAB,
'\u00A8' => 0xAC,
'\u2260' => 0xAD,
'\u0123' => 0xAE,
'\u012E' => 0xAF,
'\u012F' => 0xB0,
'\u012A' => 0xB1,
'\u2264' => 0xB2,
'\u2265' => 0xB3,
'\u012B' => 0xB4,
'\u0136' => 0xB5,
'\u2202' => 0xB6,
'\u2211' => 0xB7,
'\u0142' => 0xB8,
'\u013B' => 0xB9,
'\u013C' => 0xBA,
'\u013D' => 0xBB,
'\u013E' => 0xBC,
'\u0139' => 0xBD,
'\u013A' => 0xBE,
'\u0145' => 0xBF,
'\u0146' => 0xC0,
'\u0143' => 0xC1,
'\u00AC' => 0xC2,
'\u221A' => 0xC3,
'\u0144' => 0xC4,
'\u0147' => 0xC5,
'\u2206' => 0xC6,
'\u00AB' => 0xC7,
'\u00BB' => 0xC8,
'\u2026' => 0xC9,
'\u00A0' => 0xCA,
'\u0148' => 0xCB,
'\u0150' => 0xCC,
'\u00D5' => 0xCD,
'\u0151' => 0xCE,
'\u014C' => 0xCF,
'\u2013' => 0xD0,
'\u2014' => 0xD1,
'\u201C' => 0xD2,
'\u201D' => 0xD3,
'\u2018' => 0xD4,
'\u2019' => 0xD5,
'\u00F7' => 0xD6,
'\u05CA' => 0xD7,
'\u014D' => 0xD8,
'\u0154' => 0xD9,
'\u0155' => 0xDA,
'\u0158' => 0xDB,
'\u2039' => 0xDC,
'\u203A' => 0xDD,
'\u0159' => 0xDE,
'\u0156' => 0xDF,
'\u0157' => 0xE0,
'\u0160' => 0xE1,
'\u201A' => 0xE2,
'\u201E' => 0xE3,
'\u0161' => 0xE4,
'\u015A' => 0xE5,
'\u015B' => 0xE6,
'\u00C1' => 0xE7,
'\u0164' => 0xE8,
'\u0165' => 0xE9,
'\u00CD' => 0xEA,
'\u017D' => 0xEB,
'\u017E' => 0xEC,
'\u016A' => 0xED,
'\u00D3' => 0xEE,
'\u00D4' => 0xEF,
'\u016B' => 0xF0,
'\u016E' => 0xF1,
'\u00DA' => 0xF2,
'\u016F' => 0xF3,
'\u0170' => 0xF4,
'\u0171' => 0xF5,
'\u0172' => 0xF6,
'\u0173' => 0xF7,
'\u00DD' => 0xF8,
'\u00FD' => 0xF9,
'\u0137' => 0xFA,
'\u017B' => 0xFB,
'\u0141' => 0xFC,
'\u017C' => 0xFD,
'\u0122' => 0xFE,
'\u02C7' => 0xFF,
_ => 0x3F
};
}

View File

@@ -0,0 +1,423 @@
//
// AtariST.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents an Mac Croatian character encoding of Unicode characters.</summary>
public class MacCroatian : SingleByteEncoding
{
/// <inheritdoc />
public override string BodyName => "x-mac-croatian";
/// <inheritdoc />
public override int CodePage => 10082;
/// <inheritdoc />
public override string EncodingName => "Croatian (Mac)";
/// <inheritdoc />
public override string HeaderName => "x-mac-croatian";
/// <inheritdoc />
public override string WebName => "x-mac-croatian";
/// <inheritdoc />
public override int WindowsCodePage => 10082;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => true;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The Macintosh Croatian to Unicode character map.</summary>
protected override char[] CharTable => new[]
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
// 0x10
'\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017',
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
// 0x80
'\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8',
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
// 0x98
'\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC',
// 0xA0
'\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF',
// 0xA8
'\u00AE', '\u0160', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u017D', '\u00D8',
// 0xB0
'\u221E', '\u00B1', '\u2264', '\u2265', '\u2206', '\u00B5', '\u2202', '\u2211',
// 0xB8
'\u220F', '\u0161', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u017E', '\u00F8',
// 0xC0
'\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u0106', '\u00AB',
// 0xC8
'\u010C', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153',
// 0xD0
'\u0110', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA',
// 0xD8
'\uF8FF', '\u00A9', '\u2044', '\u20AC', '\u2039', '\u203A', '\u00C6', '\u00BB',
// 0xE0
'\u2013', '\u00B7', '\u201A', '\u201E', '\u2030', '\u00C2', '\u0107', '\u00C1',
// 0xE8
'\u010D', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4',
// 0xF0
'\u0111', '\u00D2', '\u00DA', '\u00D8', '\u00D9', '\u0131', '\u02C6', '\u02DC',
// 0xF8
'\u00AF', '\u03C0', '\u00CB', '\u02DA', '\u00B8', '\u00CA', '\u00E6', '\u02C7'
};
/// <summary>Converts a Unicode character to an Mac Croatian character</summary>
/// <returns>Mac Croatian character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(char character) => character switch
{
'\u0000' => 0x00,
'\u0001' => 0x01,
'\u0002' => 0x02,
'\u0003' => 0x03,
'\u0004' => 0x04,
'\u0005' => 0x05,
'\u0006' => 0x06,
'\u0007' => 0x07,
'\u0008' => 0x08,
'\u0009' => 0x09,
'\u000A' => 0x0A,
'\u000B' => 0x0B,
'\u000C' => 0x0C,
'\u000D' => 0x0D,
'\u000E' => 0x0E,
'\u000F' => 0x0F,
'\u0010' => 0x10,
'\u2318' => 0x11,
'\u0012' => 0x12,
'\u2713' => 0x12,
'\u0013' => 0x13,
'\u25C6' => 0x13,
'\u0014' => 0x14,
'\u0015' => 0x15,
'\u0016' => 0x16,
'\u0017' => 0x17,
'\u0018' => 0x18,
'\u0019' => 0x19,
'\u001A' => 0x1A,
'\u001B' => 0x1B,
'\u001C' => 0x1C,
'\u001D' => 0x1D,
'\u001E' => 0x1E,
'\u001F' => 0x1F,
'\u0020' => 0x20,
'\u0021' => 0x21,
'\u0022' => 0x22,
'\u0023' => 0x23,
'\u0024' => 0x24,
'\u0025' => 0x25,
'\u0026' => 0x26,
'\u0027' => 0x27,
'\u0028' => 0x28,
'\u0029' => 0x29,
'\u002A' => 0x2A,
'\u002B' => 0x2B,
'\u002C' => 0x2C,
'\u002D' => 0x2D,
'\u002E' => 0x2E,
'\u002F' => 0x2F,
'\u0030' => 0x30,
'\u0031' => 0x31,
'\u0032' => 0x32,
'\u0033' => 0x33,
'\u0034' => 0x34,
'\u0035' => 0x35,
'\u0036' => 0x36,
'\u0037' => 0x37,
'\u0038' => 0x38,
'\u0039' => 0x39,
'\u003A' => 0x3A,
'\u003B' => 0x3B,
'\u003C' => 0x3C,
'\u003D' => 0x3D,
'\u003E' => 0x3E,
'\u003F' => 0x3F,
'\u0040' => 0x40,
'\u0041' => 0x41,
'\u0042' => 0x42,
'\u0043' => 0x43,
'\u0044' => 0x44,
'\u0045' => 0x45,
'\u0046' => 0x46,
'\u0047' => 0x47,
'\u0048' => 0x48,
'\u0049' => 0x49,
'\u004A' => 0x4A,
'\u004B' => 0x4B,
'\u004C' => 0x4C,
'\u004D' => 0x4D,
'\u004E' => 0x4E,
'\u004F' => 0x4F,
'\u0050' => 0x50,
'\u0051' => 0x51,
'\u0052' => 0x52,
'\u0053' => 0x53,
'\u0054' => 0x54,
'\u0055' => 0x55,
'\u0056' => 0x56,
'\u0057' => 0x57,
'\u0058' => 0x58,
'\u0059' => 0x59,
'\u005A' => 0x5A,
'\u005B' => 0x5B,
'\u005C' => 0x5C,
'\u005D' => 0x5D,
'\u005E' => 0x5E,
'\u005F' => 0x5F,
'\u0060' => 0x60,
'\u0061' => 0x61,
'\u0062' => 0x62,
'\u0063' => 0x63,
'\u0064' => 0x64,
'\u0065' => 0x65,
'\u0066' => 0x66,
'\u0067' => 0x67,
'\u0068' => 0x68,
'\u0069' => 0x69,
'\u006A' => 0x6A,
'\u006B' => 0x6B,
'\u006C' => 0x6C,
'\u006D' => 0x6D,
'\u006E' => 0x6E,
'\u006F' => 0x6F,
'\u0070' => 0x70,
'\u0071' => 0x71,
'\u0072' => 0x72,
'\u0073' => 0x73,
'\u0074' => 0x74,
'\u0075' => 0x75,
'\u0076' => 0x76,
'\u0077' => 0x77,
'\u0078' => 0x78,
'\u0079' => 0x79,
'\u007A' => 0x7A,
'\u007B' => 0x7B,
'\u007C' => 0x7C,
'\u007D' => 0x7D,
'\u007E' => 0x7E,
'\u007F' => 0x7F,
'\u00C4' => 0x80,
'\u00C5' => 0x81,
'\u00C7' => 0x82,
'\u00C9' => 0x83,
'\u00D1' => 0x84,
'\u00D6' => 0x85,
'\u00DC' => 0x86,
'\u00E1' => 0x87,
'\u00E0' => 0x88,
'\u00E2' => 0x89,
'\u00E4' => 0x8A,
'\u00E3' => 0x8B,
'\u00E5' => 0x8C,
'\u00E7' => 0x8D,
'\u00E9' => 0x8E,
'\u00E8' => 0x8F,
'\u00EA' => 0x90,
'\u00EB' => 0x91,
'\u00ED' => 0x92,
'\u00EC' => 0x93,
'\u00EE' => 0x94,
'\u00EF' => 0x95,
'\u00F1' => 0x96,
'\u00F3' => 0x97,
'\u00F2' => 0x98,
'\u00F4' => 0x99,
'\u00F6' => 0x9A,
'\u00F5' => 0x9B,
'\u00FA' => 0x9C,
'\u00F9' => 0x9D,
'\u00FB' => 0x9E,
'\u00FC' => 0x9F,
'\u2020' => 0xA0,
'\u00B0' => 0xA1,
'\u00A2' => 0xA2,
'\u00A3' => 0xA3,
'\u00A7' => 0xA4,
'\u2022' => 0xA5,
'\u00B6' => 0xA6,
'\u00DF' => 0xA7,
'\u00AE' => 0xA8,
'\u0160' => 0xA9,
'\u2122' => 0xAA,
'\u00B4' => 0xAB,
'\u00A8' => 0xAC,
'\u2260' => 0xAD,
'\u017D' => 0xAE,
'\u00D8' => 0xAF,
'\u221E' => 0xB0,
'\u00B1' => 0xB1,
'\u2264' => 0xB2,
'\u2265' => 0xB3,
'\u2206' => 0xB4,
'\u00B5' => 0xB5,
'\u2202' => 0xB6,
'\u2211' => 0xB7,
'\u220F' => 0xB8,
'\u0161' => 0xB9,
'\u222B' => 0xBA,
'\u00AA' => 0xBB,
'\u00BA' => 0xBC,
'\u03A9' => 0xBD,
'\u017E' => 0xBE,
'\u00F8' => 0xBF,
'\u00BF' => 0xC0,
'\u00A1' => 0xC1,
'\u00AC' => 0xC2,
'\u221A' => 0xC3,
'\u0192' => 0xC4,
'\u2248' => 0xC5,
'\u0106' => 0xC6,
'\u00AB' => 0xC7,
'\u010C' => 0xC8,
'\u2026' => 0xC9,
'\u00A0' => 0xCA,
'\u00C0' => 0xCB,
'\u00C3' => 0xCC,
'\u00D5' => 0xCD,
'\u0152' => 0xCE,
'\u0153' => 0xCF,
'\u0110' => 0xD0,
'\u2014' => 0xD1,
'\u201C' => 0xD2,
'\u201D' => 0xD3,
'\u2018' => 0xD4,
'\u2019' => 0xD5,
'\u00F7' => 0xD6,
'\u25CA' => 0xD7,
'\uF8FF' => 0xD8,
'\u00A9' => 0xD9,
'\u2044' => 0xDA,
'\u20AC' => 0xDB,
'\u2039' => 0xDC,
'\u203A' => 0xDD,
'\u00C6' => 0xDE,
'\u00BB' => 0xDF,
'\u2013' => 0xE0,
'\u00B7' => 0xE1,
'\u201A' => 0xE2,
'\u201E' => 0xE3,
'\u2030' => 0xE4,
'\u00C2' => 0xE5,
'\u0107' => 0xE6,
'\u00C1' => 0xE7,
'\u010D' => 0xE8,
'\u00C8' => 0xE9,
'\u00CD' => 0xEA,
'\u00CE' => 0xEB,
'\u00CF' => 0xEC,
'\u00CC' => 0xED,
'\u00D3' => 0xEE,
'\u00D4' => 0xEF,
'\u0111' => 0xF0,
'\u00D2' => 0xF1,
'\u00DA' => 0xF2,
'\u00DB' => 0xF3,
'\u00D9' => 0xF4,
'\u0131' => 0xF5,
'\u02C6' => 0xF6,
'\u02DC' => 0xF7,
'\u00AF' => 0xF8,
'\u03C0' => 0xF9,
'\u00CB' => 0xFA,
'\u02DA' => 0xFB,
'\u00B8' => 0xFC,
'\u00CA' => 0xFD,
'\u00E6' => 0xFE,
'\u02C7' => 0xFF,
_ => 0x3F
};
}

View File

@@ -0,0 +1,424 @@
//
// AtariST.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents an Mac Cyrillic character encoding of Unicode characters.</summary>
public class MacCyrillic : SingleByteEncoding
{
/// <inheritdoc />
public override string BodyName => "x-mac-cyrillic";
/// <inheritdoc />
public override int CodePage => 10007;
/// <inheritdoc />
public override string EncodingName => "Cyrillic (Mac)";
/// <inheritdoc />
public override string HeaderName => "x-mac-cyrillic";
/// <inheritdoc />
public override string WebName => "x-mac-cyrillic";
/// <inheritdoc />
public override int WindowsCodePage => 10007;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => true;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The Macintosh Cyrillic to Unicode character map.</summary>
protected override char[] CharTable => new[]
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
// 0x10
'\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017',
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
// 0x80
'\u0410', '\u0411', '\u0412', '\u0413', '\u0414', '\u0415', '\u0416', '\u0417',
// 0x88
'\u0418', '\u0419', '\u041A', '\u041B', '\u041C', '\u041D', '\u041E', '\u041F',
// 0x90
'\u0420', '\u0421', '\u0422', '\u0423', '\u0424', '\u0425', '\u0426', '\u0427',
// 0x98
'\u0428', '\u0429', '\u042A', '\u042B', '\u042C', '\u042D', '\u042E', '\u042F',
// 0xA0
'\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u0406',
// 0xA8
'\u00AE', '\u00A9', '\u2122', '\u0402', '\u0452', '\u2260', '\u0403', '\u0453',
// 0xB0
'\u221E', '\u00B1', '\u2264', '\u2265', '\u0456', '\u00B5', '\u2202', '\u0408',
// 0xB8
'\u0404', '\u0454', '\u0407', '\u0457', '\u0409', '\u0459', '\u040A', '\u045A',
// 0xC0
'\u0458', '\u0405', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB',
// 0xC8
'\u00BB', '\u2026', '\u00A0', '\u040B', '\u045B', '\u040C', '\u045C', '\u0455',
// 0xD0
'\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u201E',
// 0xD8
'\u040E', '\u045E', '\u040F', '\u045F', '\u2116', '\u0401', '\u0451', '\u044F',
// 0xE0
'\u0430', '\u0431', '\u0432', '\u0433', '\u0434', '\u0435', '\u0436', '\u0437',
// 0xE8
'\u0438', '\u0439', '\u043A', '\u043B', '\u043C', '\u043D', '\u043E', '\u043F',
// 0xF0
'\u0440', '\u0441', '\u0442', '\u0443', '\u0444', '\u0445', '\u0446', '\u0447',
// 0xF8
'\u0448', '\u0449', '\u044A', '\u044B', '\u044C', '\u044D', '\u044E', '\u20AC'
};
/// <summary>Converts a Unicode character to an Mac Cyrillic character</summary>
/// <returns>Mac Cyrillic character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(char character) => character switch
{
'\u0000' => 0x00,
'\u0001' => 0x01,
'\u0002' => 0x02,
'\u0003' => 0x03,
'\u0004' => 0x04,
'\u0005' => 0x05,
'\u0006' => 0x06,
'\u0007' => 0x07,
'\u0008' => 0x08,
'\u0009' => 0x09,
'\u000A' => 0x0A,
'\u000B' => 0x0B,
'\u000C' => 0x0C,
'\u000D' => 0x0D,
'\u000E' => 0x0E,
'\u000F' => 0x0F,
'\u0010' => 0x10,
'\u2318' => 0x11,
'\u0012' => 0x12,
'\u2713' => 0x12,
'\u0013' => 0x13,
'\u25C6' => 0x13,
'\u0014' => 0x14,
'\uF8FF' => 0x14,
'\u0015' => 0x15,
'\u0016' => 0x16,
'\u0017' => 0x17,
'\u0018' => 0x18,
'\u0019' => 0x19,
'\u001A' => 0x1A,
'\u001B' => 0x1B,
'\u001C' => 0x1C,
'\u001D' => 0x1D,
'\u001E' => 0x1E,
'\u001F' => 0x1F,
'\u0020' => 0x20,
'\u0021' => 0x21,
'\u0022' => 0x22,
'\u0023' => 0x23,
'\u0024' => 0x24,
'\u0025' => 0x25,
'\u0026' => 0x26,
'\u0027' => 0x27,
'\u0028' => 0x28,
'\u0029' => 0x29,
'\u002A' => 0x2A,
'\u002B' => 0x2B,
'\u002C' => 0x2C,
'\u002D' => 0x2D,
'\u002E' => 0x2E,
'\u002F' => 0x2F,
'\u0030' => 0x30,
'\u0031' => 0x31,
'\u0032' => 0x32,
'\u0033' => 0x33,
'\u0034' => 0x34,
'\u0035' => 0x35,
'\u0036' => 0x36,
'\u0037' => 0x37,
'\u0038' => 0x38,
'\u0039' => 0x39,
'\u003A' => 0x3A,
'\u003B' => 0x3B,
'\u003C' => 0x3C,
'\u003D' => 0x3D,
'\u003E' => 0x3E,
'\u003F' => 0x3F,
'\u0040' => 0x40,
'\u0041' => 0x41,
'\u0042' => 0x42,
'\u0043' => 0x43,
'\u0044' => 0x44,
'\u0045' => 0x45,
'\u0046' => 0x46,
'\u0047' => 0x47,
'\u0048' => 0x48,
'\u0049' => 0x49,
'\u004A' => 0x4A,
'\u004B' => 0x4B,
'\u004C' => 0x4C,
'\u004D' => 0x4D,
'\u004E' => 0x4E,
'\u004F' => 0x4F,
'\u0050' => 0x50,
'\u0051' => 0x51,
'\u0052' => 0x52,
'\u0053' => 0x53,
'\u0054' => 0x54,
'\u0055' => 0x55,
'\u0056' => 0x56,
'\u0057' => 0x57,
'\u0058' => 0x58,
'\u0059' => 0x59,
'\u005A' => 0x5A,
'\u005B' => 0x5B,
'\u005C' => 0x5C,
'\u005D' => 0x5D,
'\u005E' => 0x5E,
'\u005F' => 0x5F,
'\u0060' => 0x60,
'\u0061' => 0x61,
'\u0062' => 0x62,
'\u0063' => 0x63,
'\u0064' => 0x64,
'\u0065' => 0x65,
'\u0066' => 0x66,
'\u0067' => 0x67,
'\u0068' => 0x68,
'\u0069' => 0x69,
'\u006A' => 0x6A,
'\u006B' => 0x6B,
'\u006C' => 0x6C,
'\u006D' => 0x6D,
'\u006E' => 0x6E,
'\u006F' => 0x6F,
'\u0070' => 0x70,
'\u0071' => 0x71,
'\u0072' => 0x72,
'\u0073' => 0x73,
'\u0074' => 0x74,
'\u0075' => 0x75,
'\u0076' => 0x76,
'\u0077' => 0x77,
'\u0078' => 0x78,
'\u0079' => 0x79,
'\u007A' => 0x7A,
'\u007B' => 0x7B,
'\u007C' => 0x7C,
'\u007D' => 0x7D,
'\u007E' => 0x7E,
'\u007F' => 0x7F,
'\u0410' => 0x80,
'\u0411' => 0x81,
'\u0412' => 0x82,
'\u0413' => 0x83,
'\u0414' => 0x84,
'\u0415' => 0x85,
'\u0416' => 0x86,
'\u0417' => 0x87,
'\u0418' => 0x88,
'\u0419' => 0x89,
'\u041A' => 0x8A,
'\u041B' => 0x8B,
'\u041C' => 0x8C,
'\u041D' => 0x8D,
'\u041E' => 0x8E,
'\u041F' => 0x8F,
'\u0420' => 0x90,
'\u0421' => 0x91,
'\u0422' => 0x92,
'\u0423' => 0x93,
'\u0424' => 0x94,
'\u0425' => 0x95,
'\u0426' => 0x96,
'\u0427' => 0x97,
'\u0428' => 0x98,
'\u0429' => 0x99,
'\u042A' => 0x9A,
'\u042B' => 0x9B,
'\u042C' => 0x9C,
'\u042D' => 0x9D,
'\u042E' => 0x9E,
'\u042F' => 0x9F,
'\u2020' => 0xA0,
'\u00B0' => 0xA1,
'\u0490' => 0xA2,
'\u00A3' => 0xA3,
'\u00A7' => 0xA4,
'\u2022' => 0xA5,
'\u00B6' => 0xA6,
'\u0406' => 0xA7,
'\u00AE' => 0xA8,
'\u00A9' => 0xA9,
'\u2122' => 0xAA,
'\u0402' => 0xAB,
'\u0452' => 0xAC,
'\u2260' => 0xAD,
'\u0403' => 0xAE,
'\u0453' => 0xAF,
'\u221E' => 0xB0,
'\u00B1' => 0xB1,
'\u2264' => 0xB2,
'\u2265' => 0xB3,
'\u0456' => 0xB4,
'\u00B5' => 0xB5,
'\u0491' => 0xB6,
'\u0408' => 0xB7,
'\u0404' => 0xB8,
'\u0454' => 0xB9,
'\u0407' => 0xBA,
'\u0457' => 0xBB,
'\u0409' => 0xBC,
'\u0459' => 0xBD,
'\u040A' => 0xBE,
'\u045A' => 0xBF,
'\u0458' => 0xC0,
'\u0405' => 0xC1,
'\u00AC' => 0xC2,
'\u221A' => 0xC3,
'\u0192' => 0xC4,
'\u2248' => 0xC5,
'\u2206' => 0xC6,
'\u00AB' => 0xC7,
'\u00BB' => 0xC8,
'\u2026' => 0xC9,
'\u00A0' => 0xCA,
'\u040B' => 0xCB,
'\u045B' => 0xCC,
'\u040C' => 0xCD,
'\u045C' => 0xCE,
'\u0455' => 0xCF,
'\u2013' => 0xD0,
'\u2014' => 0xD1,
'\u201C' => 0xD2,
'\u201D' => 0xD3,
'\u2018' => 0xD4,
'\u2019' => 0xD5,
'\u00F7' => 0xD6,
'\u201E' => 0xD7,
'\u040E' => 0xD8,
'\u045E' => 0xD9,
'\u040F' => 0xDA,
'\u045F' => 0xDB,
'\u2116' => 0xDC,
'\u0401' => 0xDD,
'\u0451' => 0xDE,
'\u044F' => 0xDF,
'\u0430' => 0xE0,
'\u0431' => 0xE1,
'\u0432' => 0xE2,
'\u0433' => 0xE3,
'\u0434' => 0xE4,
'\u0435' => 0xE5,
'\u0436' => 0xE6,
'\u0437' => 0xE7,
'\u0438' => 0xE8,
'\u0439' => 0xE9,
'\u043A' => 0xEA,
'\u043B' => 0xEB,
'\u043C' => 0xEC,
'\u043D' => 0xED,
'\u043E' => 0xEE,
'\u043F' => 0xEF,
'\u0440' => 0xF0,
'\u0441' => 0xF1,
'\u0442' => 0xF2,
'\u0443' => 0xF3,
'\u0444' => 0xF4,
'\u0445' => 0xF5,
'\u0446' => 0xF6,
'\u0447' => 0xF7,
'\u0448' => 0xF8,
'\u0449' => 0xF9,
'\u044A' => 0xFA,
'\u044B' => 0xFB,
'\u044C' => 0xFC,
'\u044D' => 0xFD,
'\u044E' => 0xFE,
'\u20AC' => 0xFF,
_ => 0x3F
};
}

View File

@@ -0,0 +1,398 @@
//
// AtariST.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents an Mac Farsi character encoding of Unicode characters.</summary>
public class MacFarsi : SingleByteEncoding
{
/// <inheritdoc />
public override string BodyName => "x-mac-farsi";
/// <inheritdoc />
public override int CodePage => 10014;
/// <inheritdoc />
public override string EncodingName => "Farsi (Mac)";
/// <inheritdoc />
public override string HeaderName => "x-mac-farsi";
/// <inheritdoc />
public override string WebName => "x-mac-farsi";
/// <inheritdoc />
public override int WindowsCodePage => 10014;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => true;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The Macintosh Farsi to Unicode character map.</summary>
protected override char[] CharTable => new[]
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
// 0x10
'\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017',
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
// 0x80
'\u00C4', '\u00A0', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u06BA', '\u00AB', '\u00E7', '\u00E9', '\u00E8',
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u2026', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
// 0x98
'\u00BB', '\u00F4', '\u00F6', '\u00F7', '\u00FA', '\u00F9', '\u00FB', '\u00FC',
// 0xA0
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u066A', '\u0026', '\u0027',
// 0xA8
'\u0028', '\u0029', '\u002A', '\u002B', '\u060C', '\u002D', '\u002E', '\u002F',
// 0xB0
'\u06F0', '\u06F1', '\u06F2', '\u06F3', '\u06F4', '\u06F5', '\u06F6', '\u06F7',
// 0xB8
'\u06F8', '\u06F9', '\u003A', '\u061B', '\u003C', '\u003D', '\u003E', '\u061F',
// 0xC0
'\u274A', '\u0621', '\u0622', '\u0623', '\u0624', '\u0625', '\u0626', '\u0627',
// 0xC8
'\u0628', '\u0629', '\u062A', '\u062B', '\u062C', '\u062D', '\u062E', '\u062F',
// 0xD0
'\u0630', '\u0631', '\u0632', '\u0633', '\u0634', '\u0635', '\u0636', '\u0637',
// 0xD8
'\u0638', '\u0639', '\u063A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0xE0
'\u0640', '\u0641', '\u0642', '\u0643', '\u0644', '\u0645', '\u0646', '\u0647',
// 0xE8
'\u0648', '\u0649', '\u064A', '\u064B', '\u064C', '\u064D', '\u064E', '\u064F',
// 0xF0
'\u0650', '\u0651', '\u0652', '\u067E', '\u0679', '\u0686', '\u06D5', '\u06A4',
// 0xF8
'\u06AF', '\u0688', '\u0691', '\u007B', '\u007C', '\u007D', '\u0698', '\u06D2'
};
/// <summary>Converts a Unicode character to an Mac Farsi character</summary>
/// <returns>Mac Farsi character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(char character) => character switch
{
'\u0000' => 0x00,
'\u0001' => 0x01,
'\u0002' => 0x02,
'\u0003' => 0x03,
'\u0004' => 0x04,
'\u0005' => 0x05,
'\u0006' => 0x06,
'\u0007' => 0x07,
'\u0008' => 0x08,
'\u0009' => 0x09,
'\u000A' => 0x0A,
'\u000B' => 0x0B,
'\u000C' => 0x0C,
'\u000D' => 0x0D,
'\u000E' => 0x0E,
'\u000F' => 0x0F,
'\u0010' => 0x10,
'\u2318' => 0x11,
'\u0012' => 0x12,
'\u2713' => 0x12,
'\u0013' => 0x13,
'\u25C6' => 0x13,
'\uF8FF' => 0x14,
'\u0014' => 0x14,
'\u0015' => 0x15,
'\u0016' => 0x16,
'\u0017' => 0x17,
'\u0018' => 0x18,
'\u0019' => 0x19,
'\u001A' => 0x1A,
'\u001B' => 0x1B,
'\u001C' => 0x1C,
'\u001D' => 0x1D,
'\u001E' => 0x1E,
'\u001F' => 0x1F,
'\u0020' => 0x20,
'\u0021' => 0x21,
'\u0022' => 0x22,
'\u0023' => 0x23,
'\u0024' => 0x24,
'\u0025' => 0x25,
'\u0026' => 0x26,
'\u0027' => 0x27,
'\u0028' => 0x28,
'\u0029' => 0x29,
'\u002A' => 0x2A,
'\u002B' => 0x2B,
'\u002C' => 0x2C,
'\u002D' => 0x2D,
'\u002E' => 0x2E,
'\u002F' => 0x2F,
'\u0030' => 0x30,
'\u0031' => 0x31,
'\u0032' => 0x32,
'\u0033' => 0x33,
'\u0034' => 0x34,
'\u0035' => 0x35,
'\u0036' => 0x36,
'\u0037' => 0x37,
'\u0038' => 0x38,
'\u0039' => 0x39,
'\u003A' => 0x3A,
'\u003B' => 0x3B,
'\u003C' => 0x3C,
'\u003D' => 0x3D,
'\u003E' => 0x3E,
'\u003F' => 0x3F,
'\u0040' => 0x40,
'\u0041' => 0x41,
'\u0042' => 0x42,
'\u0043' => 0x43,
'\u0044' => 0x44,
'\u0045' => 0x45,
'\u0046' => 0x46,
'\u0047' => 0x47,
'\u0048' => 0x48,
'\u0049' => 0x49,
'\u004A' => 0x4A,
'\u004B' => 0x4B,
'\u004C' => 0x4C,
'\u004D' => 0x4D,
'\u004E' => 0x4E,
'\u004F' => 0x4F,
'\u0050' => 0x50,
'\u0051' => 0x51,
'\u0052' => 0x52,
'\u0053' => 0x53,
'\u0054' => 0x54,
'\u0055' => 0x55,
'\u0056' => 0x56,
'\u0057' => 0x57,
'\u0058' => 0x58,
'\u0059' => 0x59,
'\u005A' => 0x5A,
'\u005B' => 0x5B,
'\u005C' => 0x5C,
'\u005D' => 0x5D,
'\u005E' => 0x5E,
'\u005F' => 0x5F,
'\u0060' => 0x60,
'\u0061' => 0x61,
'\u0062' => 0x62,
'\u0063' => 0x63,
'\u0064' => 0x64,
'\u0065' => 0x65,
'\u0066' => 0x66,
'\u0067' => 0x67,
'\u0068' => 0x68,
'\u0069' => 0x69,
'\u006A' => 0x6A,
'\u006B' => 0x6B,
'\u006C' => 0x6C,
'\u006D' => 0x6D,
'\u006E' => 0x6E,
'\u006F' => 0x6F,
'\u0070' => 0x70,
'\u0071' => 0x71,
'\u0072' => 0x72,
'\u0073' => 0x73,
'\u0074' => 0x74,
'\u0075' => 0x75,
'\u0076' => 0x76,
'\u0077' => 0x77,
'\u0078' => 0x78,
'\u0079' => 0x79,
'\u007A' => 0x7A,
'\u007B' => 0x7B,
'\u007C' => 0x7C,
'\u007D' => 0x7D,
'\u007E' => 0x7E,
'\u007F' => 0x7F,
'\u00C4' => 0x80,
'\u00A0' => 0x81,
'\u00C7' => 0x82,
'\u00C9' => 0x83,
'\u00D1' => 0x84,
'\u00D6' => 0x85,
'\u00DC' => 0x86,
'\u00E1' => 0x87,
'\u00E0' => 0x88,
'\u00E2' => 0x89,
'\u00E4' => 0x8A,
'\u06BA' => 0x8B,
'\u00AB' => 0x8C,
'\u00E7' => 0x8D,
'\u00E9' => 0x8E,
'\u00E8' => 0x8F,
'\u00EA' => 0x90,
'\u00EB' => 0x91,
'\u00ED' => 0x92,
'\u2026' => 0x93,
'\u00EE' => 0x94,
'\u00EF' => 0x95,
'\u00F1' => 0x96,
'\u00F3' => 0x97,
'\u00BB' => 0x98,
'\u00F4' => 0x99,
'\u00F6' => 0x9A,
'\u00F7' => 0x9B,
'\u00FA' => 0x9C,
'\u00F9' => 0x9D,
'\u00FB' => 0x9E,
'\u00FC' => 0x9F,
'\u066A' => 0xA5,
'\u060C' => 0xAC,
'\u06F0' => 0xB0,
'\u06F1' => 0xB1,
'\u06F2' => 0xB2,
'\u06F3' => 0xB3,
'\u06F4' => 0xB4,
'\u06F5' => 0xB5,
'\u06F6' => 0xB6,
'\u06F7' => 0xB7,
'\u06F8' => 0xB8,
'\u06F9' => 0xB9,
'\u061B' => 0xBB,
'\u061F' => 0xBF,
'\u274A' => 0xC0,
'\u0621' => 0xC1,
'\u0622' => 0xC2,
'\u0623' => 0xC3,
'\u0624' => 0xC4,
'\u0625' => 0xC5,
'\u0626' => 0xC6,
'\u0627' => 0xC7,
'\u0628' => 0xC8,
'\u0629' => 0xC9,
'\u062A' => 0xCA,
'\u062B' => 0xCB,
'\u062C' => 0xCC,
'\u062D' => 0xCD,
'\u062E' => 0xCE,
'\u062F' => 0xCF,
'\u0630' => 0xD0,
'\u0631' => 0xD1,
'\u0632' => 0xD2,
'\u0633' => 0xD3,
'\u0634' => 0xD4,
'\u0635' => 0xD5,
'\u0636' => 0xD6,
'\u0637' => 0xD7,
'\u0638' => 0xD8,
'\u0639' => 0xD9,
'\u063A' => 0xDA,
'\u0640' => 0xE0,
'\u0641' => 0xE1,
'\u0642' => 0xE2,
'\u0643' => 0xE3,
'\u0644' => 0xE4,
'\u0645' => 0xE5,
'\u0646' => 0xE6,
'\u0647' => 0xE7,
'\u0648' => 0xE8,
'\u0649' => 0xE9,
'\u064A' => 0xEA,
'\u064B' => 0xEB,
'\u064C' => 0xEC,
'\u064D' => 0xED,
'\u064E' => 0xEE,
'\u064F' => 0xEF,
'\u0650' => 0xF0,
'\u0651' => 0xF1,
'\u0652' => 0xF2,
'\u067E' => 0xF3,
'\u0679' => 0xF4,
'\u0686' => 0xF5,
'\u06D5' => 0xF6,
'\u06A4' => 0xF7,
'\u06AF' => 0xF8,
'\u0688' => 0xF9,
'\u0691' => 0xFA,
'\u0698' => 0xFE,
'\u06D2' => 0xFF,
_ => 0x3F
};
}

View File

@@ -0,0 +1,424 @@
//
// AtariST.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents an Mac Greek character encoding of Unicode characters.</summary>
public class MacGreek : SingleByteEncoding
{
/// <inheritdoc />
public override string BodyName => "x-mac-greek";
/// <inheritdoc />
public override int CodePage => 10006;
/// <inheritdoc />
public override string EncodingName => "Greek (Mac)";
/// <inheritdoc />
public override string HeaderName => "x-mac-greek";
/// <inheritdoc />
public override string WebName => "x-mac-greek";
/// <inheritdoc />
public override int WindowsCodePage => 10006;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => true;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The Macintosh Greek to Unicode character map.</summary>
protected override char[] CharTable => new[]
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
// 0x10
'\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017',
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
// 0x80
'\u00C4', '\u00B9', '\u00B2', '\u00C9', '\u00B3', '\u00D6', '\u00DC', '\u0385',
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u0384', '\u00A8', '\u00E7', '\u00E9', '\u00E8',
// 0x90
'\u00EA', '\u00EB', '\u00A3', '\u2122', '\u00EE', '\u00EF', '\u2022', '\u00BD',
// 0x98
'\u2030', '\u00F4', '\u00F6', '\u00A6', '\u20AC', '\u00F9', '\u00FB', '\u00FC',
// 0xA0
'\u2020', '\u0393', '\u0394', '\u0398', '\u039B', '\u039E', '\u03A0', '\u00DF',
// 0xA8
'\u00AE', '\u00A9', '\u03A3', '\u03AA', '\u00A7', '\u2260', '\u00B0', '\u00B7',
// 0xB0
'\u0391', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u0392', '\u0395', '\u0396',
// 0xB8
'\u0397', '\u0399', '\u039A', '\u039C', '\u03A6', '\u03AB', '\u03A8', '\u03A9',
// 0xC0
'\u03AC', '\u039D', '\u00AC', '\u039F', '\u03A1', '\u2248', '\u03A4', '\u00AB',
// 0xC8
'\u00BB', '\u2026', '\u00A0', '\u03A5', '\u03A7', '\u0386', '\u0388', '\u0153',
// 0xD0
'\u2013', '\u2015', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u0389',
// 0xD8
'\u038A', '\u038C', '\u038E', '\u03AD', '\u03AE', '\u03AF', '\u03CC', '\u038F',
// 0xE0
'\u03CD', '\u03B1', '\u03B2', '\u03C8', '\u03B4', '\u03B5', '\u03C6', '\u03B3',
// 0xE8
'\u03B7', '\u03B9', '\u03BE', '\u03BA', '\u03BB', '\u03BC', '\u03BD', '\u03BF',
// 0xF0
'\u03C0', '\u03CE', '\u03C1', '\u03C3', '\u03C4', '\u03B8', '\u03C9', '\u03C2',
// 0xF8
'\u03C7', '\u03C5', '\u03B6', '\u03CA', '\u03CB', '\u0390', '\u03B0', '\u00AD'
};
/// <summary>Converts a Unicode character to an Mac Greek character</summary>
/// <returns>Mac Greek character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(char character) => character switch
{
'\u0000' => 0x00,
'\u0001' => 0x01,
'\u0002' => 0x02,
'\u0003' => 0x03,
'\u0004' => 0x04,
'\u0005' => 0x05,
'\u0006' => 0x06,
'\u0007' => 0x07,
'\u0008' => 0x08,
'\u0009' => 0x09,
'\u000A' => 0x0A,
'\u000B' => 0x0B,
'\u000C' => 0x0C,
'\u000D' => 0x0D,
'\u000E' => 0x0E,
'\u000F' => 0x0F,
'\u0010' => 0x10,
'\u2318' => 0x11,
'\u0012' => 0x12,
'\u2713' => 0x12,
'\u0013' => 0x13,
'\u25C6' => 0x13,
'\u0014' => 0x14,
'\uF8FF' => 0x14,
'\u0015' => 0x15,
'\u0016' => 0x16,
'\u0017' => 0x17,
'\u0018' => 0x18,
'\u0019' => 0x19,
'\u001A' => 0x1A,
'\u001B' => 0x1B,
'\u001C' => 0x1C,
'\u001D' => 0x1D,
'\u001E' => 0x1E,
'\u001F' => 0x1F,
'\u0020' => 0x20,
'\u0021' => 0x21,
'\u0022' => 0x22,
'\u0023' => 0x23,
'\u0024' => 0x24,
'\u0025' => 0x25,
'\u0026' => 0x26,
'\u0027' => 0x27,
'\u0028' => 0x28,
'\u0029' => 0x29,
'\u002A' => 0x2A,
'\u002B' => 0x2B,
'\u002C' => 0x2C,
'\u002D' => 0x2D,
'\u002E' => 0x2E,
'\u002F' => 0x2F,
'\u0030' => 0x30,
'\u0031' => 0x31,
'\u0032' => 0x32,
'\u0033' => 0x33,
'\u0034' => 0x34,
'\u0035' => 0x35,
'\u0036' => 0x36,
'\u0037' => 0x37,
'\u0038' => 0x38,
'\u0039' => 0x39,
'\u003A' => 0x3A,
'\u003B' => 0x3B,
'\u003C' => 0x3C,
'\u003D' => 0x3D,
'\u003E' => 0x3E,
'\u003F' => 0x3F,
'\u0040' => 0x40,
'\u0041' => 0x41,
'\u0042' => 0x42,
'\u0043' => 0x43,
'\u0044' => 0x44,
'\u0045' => 0x45,
'\u0046' => 0x46,
'\u0047' => 0x47,
'\u0048' => 0x48,
'\u0049' => 0x49,
'\u004A' => 0x4A,
'\u004B' => 0x4B,
'\u004C' => 0x4C,
'\u004D' => 0x4D,
'\u004E' => 0x4E,
'\u004F' => 0x4F,
'\u0050' => 0x50,
'\u0051' => 0x51,
'\u0052' => 0x52,
'\u0053' => 0x53,
'\u0054' => 0x54,
'\u0055' => 0x55,
'\u0056' => 0x56,
'\u0057' => 0x57,
'\u0058' => 0x58,
'\u0059' => 0x59,
'\u005A' => 0x5A,
'\u005B' => 0x5B,
'\u005C' => 0x5C,
'\u005D' => 0x5D,
'\u005E' => 0x5E,
'\u005F' => 0x5F,
'\u0060' => 0x60,
'\u0061' => 0x61,
'\u0062' => 0x62,
'\u0063' => 0x63,
'\u0064' => 0x64,
'\u0065' => 0x65,
'\u0066' => 0x66,
'\u0067' => 0x67,
'\u0068' => 0x68,
'\u0069' => 0x69,
'\u006A' => 0x6A,
'\u006B' => 0x6B,
'\u006C' => 0x6C,
'\u006D' => 0x6D,
'\u006E' => 0x6E,
'\u006F' => 0x6F,
'\u0070' => 0x70,
'\u0071' => 0x71,
'\u0072' => 0x72,
'\u0073' => 0x73,
'\u0074' => 0x74,
'\u0075' => 0x75,
'\u0076' => 0x76,
'\u0077' => 0x77,
'\u0078' => 0x78,
'\u0079' => 0x79,
'\u007A' => 0x7A,
'\u007B' => 0x7B,
'\u007C' => 0x7C,
'\u007D' => 0x7D,
'\u007E' => 0x7E,
'\u007F' => 0x7F,
'\u00C4' => 0x80,
'\u00B9' => 0x81,
'\u00B2' => 0x82,
'\u00C9' => 0x83,
'\u00B3' => 0x84,
'\u00D6' => 0x85,
'\u00DC' => 0x86,
'\u0385' => 0x87,
'\u00E0' => 0x88,
'\u00E2' => 0x89,
'\u00E4' => 0x8A,
'\u0384' => 0x8B,
'\u00A8' => 0x8C,
'\u00E7' => 0x8D,
'\u00E9' => 0x8E,
'\u00E8' => 0x8F,
'\u00EA' => 0x90,
'\u00EB' => 0x91,
'\u00A3' => 0x92,
'\u2122' => 0x93,
'\u00EE' => 0x94,
'\u00EF' => 0x95,
'\u2022' => 0x96,
'\u00BD' => 0x97,
'\u2030' => 0x98,
'\u00F4' => 0x99,
'\u00F6' => 0x9A,
'\u00A6' => 0x9B,
'\u20AC' => 0x9C,
'\u00F9' => 0x9D,
'\u00FB' => 0x9E,
'\u00FC' => 0x9F,
'\u2020' => 0xA0,
'\u0393' => 0xA1,
'\u0394' => 0xA2,
'\u0398' => 0xA3,
'\u039B' => 0xA4,
'\u039E' => 0xA5,
'\u03A0' => 0xA6,
'\u00DF' => 0xA7,
'\u00AE' => 0xA8,
'\u00A9' => 0xA9,
'\u03A3' => 0xAA,
'\u03AA' => 0xAB,
'\u00A7' => 0xAC,
'\u2260' => 0xAD,
'\u00B0' => 0xAE,
'\u00B7' => 0xAF,
'\u0391' => 0xB0,
'\u00B1' => 0xB1,
'\u2264' => 0xB2,
'\u2265' => 0xB3,
'\u00A5' => 0xB4,
'\u0392' => 0xB5,
'\u0395' => 0xB6,
'\u0396' => 0xB7,
'\u0397' => 0xB8,
'\u0399' => 0xB9,
'\u039A' => 0xBA,
'\u039C' => 0xBB,
'\u03A6' => 0xBC,
'\u03AB' => 0xBD,
'\u03A8' => 0xBE,
'\u03A9' => 0xBF,
'\u03AC' => 0xC0,
'\u039D' => 0xC1,
'\u00AC' => 0xC2,
'\u039F' => 0xC3,
'\u03A1' => 0xC4,
'\u2248' => 0xC5,
'\u03A4' => 0xC6,
'\u00AB' => 0xC7,
'\u00BB' => 0xC8,
'\u2026' => 0xC9,
'\u00A0' => 0xCA,
'\u03A5' => 0xCB,
'\u03A7' => 0xCC,
'\u0386' => 0xCD,
'\u0388' => 0xCE,
'\u0153' => 0xCF,
'\u2013' => 0xD0,
'\u2015' => 0xD1,
'\u201C' => 0xD2,
'\u201D' => 0xD3,
'\u2018' => 0xD4,
'\u2019' => 0xD5,
'\u00F7' => 0xD6,
'\u0389' => 0xD7,
'\u038A' => 0xD8,
'\u038C' => 0xD9,
'\u038E' => 0xDA,
'\u03AD' => 0xDB,
'\u03AE' => 0xDC,
'\u03AF' => 0xDD,
'\u03CC' => 0xDE,
'\u038F' => 0xDF,
'\u03CD' => 0xE0,
'\u03B1' => 0xE1,
'\u03B2' => 0xE2,
'\u03C8' => 0xE3,
'\u03B4' => 0xE4,
'\u03B5' => 0xE5,
'\u03C6' => 0xE6,
'\u03B3' => 0xE7,
'\u03B7' => 0xE8,
'\u03B9' => 0xE9,
'\u03BE' => 0xEA,
'\u03BA' => 0xEB,
'\u03BB' => 0xEC,
'\u03BC' => 0xED,
'\u03BD' => 0xEE,
'\u03BF' => 0xEF,
'\u03C0' => 0xF0,
'\u03CE' => 0xF1,
'\u03C1' => 0xF2,
'\u03C3' => 0xF3,
'\u03C4' => 0xF4,
'\u03B8' => 0xF5,
'\u03C9' => 0xF6,
'\u03C2' => 0xF7,
'\u03C7' => 0xF8,
'\u03C5' => 0xF9,
'\u03B6' => 0xFA,
'\u03CA' => 0xFB,
'\u03CB' => 0xFC,
'\u0390' => 0xFD,
'\u03B0' => 0xFE,
'\u00AD' => 0xFF,
_ => 0x3F
};
}

View File

@@ -0,0 +1,389 @@
//
// AtariST.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents an Mac Hebrew character encoding of Unicode characters.</summary>
public class MacHebrew : SingleByteEncoding
{
/// <inheritdoc />
public override string BodyName => "x-mac-hebrew";
/// <inheritdoc />
public override int CodePage => 10005;
/// <inheritdoc />
public override string EncodingName => "Hebrew (Mac)";
/// <inheritdoc />
public override string HeaderName => "x-mac-hebrew";
/// <inheritdoc />
public override string WebName => "x-mac-hebrew";
/// <inheritdoc />
public override int WindowsCodePage => 10005;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => true;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The Macintosh Hebrew to Unicode character map.</summary>
// TODO: 0x81 => 0x05F2+0x05B7
// TODO: 0xC0 => 0xF86A+0x05DC+0x05B9
// TODO: 0xDE => 0x05B8+0xF87F
protected override char[] CharTable => new[]
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
// 0x10
'\u0010', '\u0011', '\u0012', '\u0013', '\uF8FF', '\u0015', '\u0016', '\u0017',
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
// 0x80
'\u00C4', '\u0081', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8',
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
// 0x98
'\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC',
// 0xA0
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u20AA', '\u0027',
// 0xA8
'\u0029', '\u0028', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
// 0xB0
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
// 0xB8
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
// 0xC0
'\uF86A', '\u201E', '\uF89B', '\uF89C', '\uF89D', '\uF89E', '\u05BC', '\uFB4B',
// 0xC8
'\uFB35', '\u2026', '\u00A0', '\u05B8', '\u05B7', '\u05B5', '\u05B6', '\u05B4',
// 0xD0
'\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\uFB2A', '\uFB2B',
// 0xD8
'\u05BF', '\u05B0', '\u05B2', '\u05B1', '\u05BB', '\u05B9', '\u05B8', '\u05B3',
// 0xE0
'\u05D0', '\u05D1', '\u05D2', '\u05D3', '\u05D4', '\u05D5', '\u05D6', '\u05D7',
// 0xE8
'\u05D8', '\u05D9', '\u05DA', '\u05DB', '\u05DC', '\u05DD', '\u05DE', '\u05DF',
// 0xF0
'\u05E0', '\u05E1', '\u05E2', '\u05E3', '\u05E4', '\u05E5', '\u05E6', '\u05E7',
// 0xF8
'\u05E8', '\u05E9', '\u05EA', '\u007D', '\u005D', '\u007B', '\u005B', '\u007C'
};
/// <summary>Converts a Unicode character to an Mac Hebrew character</summary>
/// <returns>Mac Hebrew character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(char character) => character switch
{
'\u0000' => 0x00,
'\u0001' => 0x01,
'\u0002' => 0x02,
'\u0003' => 0x03,
'\u0004' => 0x04,
'\u0005' => 0x05,
'\u0006' => 0x06,
'\u0007' => 0x07,
'\u0008' => 0x08,
'\u0009' => 0x09,
'\u000A' => 0x0A,
'\u000B' => 0x0B,
'\u000C' => 0x0C,
'\u000D' => 0x0D,
'\u000E' => 0x0E,
'\u000F' => 0x0F,
'\u0010' => 0x10,
'\u2318' => 0x11,
'\u0012' => 0x12,
'\u2713' => 0x12,
'\u0013' => 0x13,
'\u25C6' => 0x13,
'\u0014' => 0x14,
'\uF8FF' => 0x14,
'\u0015' => 0x15,
'\u0016' => 0x16,
'\u0017' => 0x17,
'\u0018' => 0x18,
'\u0019' => 0x19,
'\u001A' => 0x1A,
'\u001B' => 0x1B,
'\u001C' => 0x1C,
'\u001D' => 0x1D,
'\u001E' => 0x1E,
'\u001F' => 0x1F,
'\u0020' => 0x20,
'\u0021' => 0x21,
'\u0022' => 0x22,
'\u0023' => 0x23,
'\u0024' => 0x24,
'\u0025' => 0x25,
'\u0026' => 0x26,
'\u0027' => 0x27,
'\u0028' => 0x28,
'\u0029' => 0x29,
'\u002A' => 0x2A,
'\u002B' => 0x2B,
'\u002C' => 0x2C,
'\u002D' => 0x2D,
'\u002E' => 0x2E,
'\u002F' => 0x2F,
'\u0030' => 0x30,
'\u0031' => 0x31,
'\u0032' => 0x32,
'\u0033' => 0x33,
'\u0034' => 0x34,
'\u0035' => 0x35,
'\u0036' => 0x36,
'\u0037' => 0x37,
'\u0038' => 0x38,
'\u0039' => 0x39,
'\u003A' => 0x3A,
'\u003B' => 0x3B,
'\u003C' => 0x3C,
'\u003D' => 0x3D,
'\u003E' => 0x3E,
'\u003F' => 0x3F,
'\u0040' => 0x40,
'\u0041' => 0x41,
'\u0042' => 0x42,
'\u0043' => 0x43,
'\u0044' => 0x44,
'\u0045' => 0x45,
'\u0046' => 0x46,
'\u0047' => 0x47,
'\u0048' => 0x48,
'\u0049' => 0x49,
'\u004A' => 0x4A,
'\u004B' => 0x4B,
'\u004C' => 0x4C,
'\u004D' => 0x4D,
'\u004E' => 0x4E,
'\u004F' => 0x4F,
'\u0050' => 0x50,
'\u0051' => 0x51,
'\u0052' => 0x52,
'\u0053' => 0x53,
'\u0054' => 0x54,
'\u0055' => 0x55,
'\u0056' => 0x56,
'\u0057' => 0x57,
'\u0058' => 0x58,
'\u0059' => 0x59,
'\u005A' => 0x5A,
'\u005B' => 0x5B,
'\u005C' => 0x5C,
'\u005D' => 0x5D,
'\u005E' => 0x5E,
'\u005F' => 0x5F,
'\u0060' => 0x60,
'\u0061' => 0x61,
'\u0062' => 0x62,
'\u0063' => 0x63,
'\u0064' => 0x64,
'\u0065' => 0x65,
'\u0066' => 0x66,
'\u0067' => 0x67,
'\u0068' => 0x68,
'\u0069' => 0x69,
'\u006A' => 0x6A,
'\u006B' => 0x6B,
'\u006C' => 0x6C,
'\u006D' => 0x6D,
'\u006E' => 0x6E,
'\u006F' => 0x6F,
'\u0070' => 0x70,
'\u0071' => 0x71,
'\u0072' => 0x72,
'\u0073' => 0x73,
'\u0074' => 0x74,
'\u0075' => 0x75,
'\u0076' => 0x76,
'\u0077' => 0x77,
'\u0078' => 0x78,
'\u0079' => 0x79,
'\u007A' => 0x7A,
'\u007B' => 0x7B,
'\u007C' => 0x7C,
'\u007D' => 0x7D,
'\u007E' => 0x7E,
'\u007F' => 0x7F,
'\u00C4' => 0x80,
'\u00C7' => 0x82,
'\u00C9' => 0x83,
'\u00D1' => 0x84,
'\u00D6' => 0x85,
'\u00DC' => 0x86,
'\u00E1' => 0x87,
'\u00E0' => 0x88,
'\u00E2' => 0x89,
'\u00E4' => 0x8A,
'\u00E3' => 0x8B,
'\u00E5' => 0x8C,
'\u00E7' => 0x8D,
'\u00E9' => 0x8E,
'\u00E8' => 0x8F,
'\u00EA' => 0x90,
'\u00EB' => 0x91,
'\u00ED' => 0x92,
'\u00EC' => 0x93,
'\u00EE' => 0x94,
'\u00EF' => 0x95,
'\u00F1' => 0x96,
'\u00F3' => 0x97,
'\u00F2' => 0x98,
'\u00F4' => 0x99,
'\u00F6' => 0x9A,
'\u00F5' => 0x9B,
'\u00FA' => 0x9C,
'\u00F9' => 0x9D,
'\u00FB' => 0x9E,
'\u00FC' => 0x9F,
'\u20AA' => 0xA6,
'\u201E' => 0xC1,
'\uF89B' => 0xC2,
'\uF89C' => 0xC3,
'\uF89D' => 0xC4,
'\uF89E' => 0xC5,
'\u05BC' => 0xC6,
'\uFB4B' => 0xC7,
'\uFB35' => 0xC8,
'\u2026' => 0xC9,
'\u00A0' => 0xCA,
'\u05B8' => 0xCB,
'\u05B7' => 0xCC,
'\u05B5' => 0xCD,
'\u05B6' => 0xCE,
'\u05B4' => 0xCF,
'\u2013' => 0xD0,
'\u2014' => 0xD1,
'\u201C' => 0xD2,
'\u201D' => 0xD3,
'\u2018' => 0xD4,
'\u2019' => 0xD5,
'\uFB2A' => 0xD6,
'\uFB2B' => 0xD7,
'\u05BF' => 0xD8,
'\u05B0' => 0xD9,
'\u05B2' => 0xDA,
'\u05B1' => 0xDB,
'\u05BB' => 0xDC,
'\u05B9' => 0xDD,
'\u05B3' => 0xDF,
'\u05D0' => 0xE0,
'\u05D1' => 0xE1,
'\u05D2' => 0xE2,
'\u05D3' => 0xE3,
'\u05D4' => 0xE4,
'\u05D5' => 0xE5,
'\u05D6' => 0xE6,
'\u05D7' => 0xE7,
'\u05D8' => 0xE8,
'\u05D9' => 0xE9,
'\u05DA' => 0xEA,
'\u05DB' => 0xEB,
'\u05DC' => 0xEC,
'\u05DD' => 0xED,
'\u05DE' => 0xEE,
'\u05DF' => 0xEF,
'\u05E0' => 0xF0,
'\u05E1' => 0xF1,
'\u05E2' => 0xF2,
'\u05E3' => 0xF3,
'\u05E4' => 0xF4,
'\u05E5' => 0xF5,
'\u05E6' => 0xF6,
'\u05E7' => 0xF7,
'\u05E8' => 0xF8,
'\u05E9' => 0xF9,
'\u05EA' => 0xFA,
_ => 0x3F
};
}

View File

@@ -0,0 +1,424 @@
//
// MacRoman.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents an Apple Mac character encoding of Unicode characters.</summary>
public class MacRoman : SingleByteEncoding
{
/// <inheritdoc />
public override string BodyName => "macintosh";
/// <inheritdoc />
public override int CodePage => 10000;
/// <inheritdoc />
public override string EncodingName => "Western European (Mac)";
/// <inheritdoc />
public override string HeaderName => "macintosh";
/// <inheritdoc />
public override string WebName => "macintosh";
/// <inheritdoc />
public override int WindowsCodePage => 10000;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => true;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The Mac to Unicode character map. MacRoman is a superset of LisaRoman.</summary>
protected override char[] CharTable => new[]
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
// 0x10
'\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017',
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
// 0x80
'\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8',
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
// 0x98
'\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC',
// 0xA0
'\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF',
// 0xA8
'\u00AE', '\u00A9', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u00C6', '\u00D8',
// 0xB0
'\u221E', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u2202', '\u2211',
// 0xB8
'\u220F', '\u03C0', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u00E6', '\u00F8',
// 0xC0
'\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB',
// 0xC8
'\u00BB', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153',
// 0xD0
'\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA',
// 0xD8
'\u00FF', '\u0178', '\u2044', '\u20AC', '\u2039', '\u203A', '\uFB01', '\uFB02',
// 0xE0
'\u2021', '\u00B7', '\u201A', '\u201E', '\u2030', '\u00C2', '\u00CA', '\u00C1',
// 0xE8
'\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4',
// 0xF0
'\uF8FF', '\u00D2', '\u00DA', '\u00DB', '\u00D9', '\u0131', '\u02C6', '\u02DC',
// 0xF8
'\u00AF', '\u02D8', '\u02D9', '\u02DA', '\u00B8', '\u02DD', '\u02DB', '\u02C7'
};
/// <summary>Converts a Unicode character to an MacRoman character</summary>
/// <returns>MacRoman character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(char character) => character switch
{
'\u0000' => 0x00,
'\u0001' => 0x01,
'\u0002' => 0x02,
'\u0003' => 0x03,
'\u0004' => 0x04,
'\u0005' => 0x05,
'\u0006' => 0x06,
'\u0007' => 0x07,
'\u0008' => 0x08,
'\u0009' => 0x09,
'\u000A' => 0x0A,
'\u000B' => 0x0B,
'\u000C' => 0x0C,
'\u000D' => 0x0D,
'\u000E' => 0x0E,
'\u000F' => 0x0F,
'\u0010' => 0x10,
'\u0011' => 0x11,
'\u2318' => 0x11,
'\u0012' => 0x12,
'\u2713' => 0x12,
'\u0013' => 0x13,
'\u25C6' => 0x13,
'\u0014' => 0x14,
'\u0015' => 0x15,
'\u0016' => 0x16,
'\u0017' => 0x17,
'\u0018' => 0x18,
'\u0019' => 0x19,
'\u001A' => 0x1A,
'\u001B' => 0x1B,
'\u001C' => 0x1C,
'\u001D' => 0x1D,
'\u001E' => 0x1E,
'\u001F' => 0x1F,
'\u0020' => 0x20,
'\u0021' => 0x21,
'\u0022' => 0x22,
'\u0023' => 0x23,
'\u0024' => 0x24,
'\u0025' => 0x25,
'\u0026' => 0x26,
'\u0027' => 0x27,
'\u0028' => 0x28,
'\u0029' => 0x29,
'\u002A' => 0x2A,
'\u002B' => 0x2B,
'\u002C' => 0x2C,
'\u002D' => 0x2D,
'\u002E' => 0x2E,
'\u002F' => 0x2F,
'\u0030' => 0x30,
'\u0031' => 0x31,
'\u0032' => 0x32,
'\u0033' => 0x33,
'\u0034' => 0x34,
'\u0035' => 0x35,
'\u0036' => 0x36,
'\u0037' => 0x37,
'\u0038' => 0x38,
'\u0039' => 0x39,
'\u003A' => 0x3A,
'\u003B' => 0x3B,
'\u003C' => 0x3C,
'\u003D' => 0x3D,
'\u003E' => 0x3E,
'\u003F' => 0x3F,
'\u0040' => 0x40,
'\u0041' => 0x41,
'\u0042' => 0x42,
'\u0043' => 0x43,
'\u0044' => 0x44,
'\u0045' => 0x45,
'\u0046' => 0x46,
'\u0047' => 0x47,
'\u0048' => 0x48,
'\u0049' => 0x49,
'\u004A' => 0x4A,
'\u004B' => 0x4B,
'\u004C' => 0x4C,
'\u004D' => 0x4D,
'\u004E' => 0x4E,
'\u004F' => 0x4F,
'\u0050' => 0x50,
'\u0051' => 0x51,
'\u0052' => 0x52,
'\u0053' => 0x53,
'\u0054' => 0x54,
'\u0055' => 0x55,
'\u0056' => 0x56,
'\u0057' => 0x57,
'\u0058' => 0x58,
'\u0059' => 0x59,
'\u005A' => 0x5A,
'\u005B' => 0x5B,
'\u005C' => 0x5C,
'\u005D' => 0x5D,
'\u005E' => 0x5E,
'\u005F' => 0x5F,
'\u0060' => 0x60,
'\u0061' => 0x61,
'\u0062' => 0x62,
'\u0063' => 0x63,
'\u0064' => 0x64,
'\u0065' => 0x65,
'\u0066' => 0x66,
'\u0067' => 0x67,
'\u0068' => 0x68,
'\u0069' => 0x69,
'\u006A' => 0x6A,
'\u006B' => 0x6B,
'\u006C' => 0x6C,
'\u006D' => 0x6D,
'\u006E' => 0x6E,
'\u006F' => 0x6F,
'\u0070' => 0x70,
'\u0071' => 0x71,
'\u0072' => 0x72,
'\u0073' => 0x73,
'\u0074' => 0x74,
'\u0075' => 0x75,
'\u0076' => 0x76,
'\u0077' => 0x77,
'\u0078' => 0x78,
'\u0079' => 0x79,
'\u007A' => 0x7A,
'\u007B' => 0x7B,
'\u007C' => 0x7C,
'\u007D' => 0x7D,
'\u007E' => 0x7E,
'\u007F' => 0x7F,
'\u00C4' => 0x80,
'\u00C5' => 0x81,
'\u00C7' => 0x82,
'\u00C9' => 0x83,
'\u00D1' => 0x84,
'\u00D6' => 0x85,
'\u00DC' => 0x86,
'\u00E1' => 0x87,
'\u00E0' => 0x88,
'\u00E2' => 0x89,
'\u00E4' => 0x8A,
'\u00E3' => 0x8B,
'\u00E5' => 0x8C,
'\u00E7' => 0x8D,
'\u00E9' => 0x8E,
'\u00E8' => 0x8F,
'\u00EA' => 0x90,
'\u00EB' => 0x91,
'\u00ED' => 0x92,
'\u00EC' => 0x93,
'\u00EE' => 0x94,
'\u00EF' => 0x95,
'\u00F1' => 0x96,
'\u00F3' => 0x97,
'\u00F2' => 0x98,
'\u00F4' => 0x99,
'\u00F6' => 0x9A,
'\u00F5' => 0x9B,
'\u00FA' => 0x9C,
'\u00F9' => 0x9D,
'\u00FB' => 0x9E,
'\u00FC' => 0x9F,
'\u2020' => 0xA0,
'\u00B0' => 0xA1,
'\u00A2' => 0xA2,
'\u00A3' => 0xA3,
'\u00A7' => 0xA4,
'\u2022' => 0xA5,
'\u00B6' => 0xA6,
'\u00DF' => 0xA7,
'\u00AE' => 0xA8,
'\u00A9' => 0xA9,
'\u2122' => 0xAA,
'\u00B4' => 0xAB,
'\u00A8' => 0xAC,
'\u2260' => 0xAD,
'\u00C6' => 0xAE,
'\u00D8' => 0xAF,
'\u221E' => 0xB0,
'\u00B1' => 0xB1,
'\u2264' => 0xB2,
'\u2265' => 0xB3,
'\u00A5' => 0xB4,
'\u00B5' => 0xB5,
'\u2202' => 0xB6,
'\u2211' => 0xB7,
'\u220F' => 0xB8,
'\u03C0' => 0xB9,
'\u222B' => 0xBA,
'\u00AA' => 0xBB,
'\u00BA' => 0xBC,
'\u03A9' => 0xBD,
'\u00E6' => 0xBE,
'\u00F8' => 0xBF,
'\u00BF' => 0xC0,
'\u00A1' => 0xC1,
'\u00AC' => 0xC2,
'\u221A' => 0xC3,
'\u0192' => 0xC4,
'\u2248' => 0xC5,
'\u2206' => 0xC6,
'\u00AB' => 0xC7,
'\u00BB' => 0xC8,
'\u2026' => 0xC9,
'\u00A0' => 0xCA,
'\u00C0' => 0xCB,
'\u00C3' => 0xCC,
'\u00D5' => 0xCD,
'\u0152' => 0xCE,
'\u0153' => 0xCF,
'\u2013' => 0xD0,
'\u2014' => 0xD1,
'\u201C' => 0xD2,
'\u201D' => 0xD3,
'\u2018' => 0xD4,
'\u2019' => 0xD5,
'\u00F7' => 0xD6,
'\u25CA' => 0xD7,
'\u00FF' => 0xD8,
'\u0178' => 0xD9,
'\u2044' => 0xDA,
'\u20AC' => 0xDB,
'\u2039' => 0xDC,
'\u203A' => 0xDD,
'\uFB01' => 0xDE,
'\uFB02' => 0xDF,
'\u2021' => 0xE0,
'\u00B7' => 0xE1,
'\u201A' => 0xE2,
'\u201E' => 0xE3,
'\u2030' => 0xE4,
'\u00C2' => 0xE5,
'\u00CA' => 0xE6,
'\u00C1' => 0xE7,
'\u00CB' => 0xE8,
'\u00C8' => 0xE9,
'\u00CD' => 0xEA,
'\u00CE' => 0xEB,
'\u00CF' => 0xEC,
'\u00CC' => 0xED,
'\u00D3' => 0xEE,
'\u00D4' => 0xEF,
'\uF8FF' => 0xF0,
'\u00D2' => 0xF1,
'\u00DA' => 0xF2,
'\u00DB' => 0xF3,
'\u00D9' => 0xF4,
'\u0131' => 0xF5,
'\u02C6' => 0xF6,
'\u02DC' => 0xF7,
'\u00AF' => 0xF8,
'\u02D8' => 0xF9,
'\u02D9' => 0xFA,
'\u02DA' => 0xFB,
'\u00B8' => 0xFC,
'\u02DD' => 0xFD,
'\u02DB' => 0xFE,
'\u02C7' => 0xFF,
_ => 0x3F
};
}

View File

@@ -0,0 +1,423 @@
//
// MacRomanian.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents an Apple Mac character encoding of Unicode characters.</summary>
public class MacRomanian : SingleByteEncoding
{
/// <inheritdoc />
public override string BodyName => "x-mac-romanian";
/// <inheritdoc />
public override int CodePage => 10010;
/// <inheritdoc />
public override string EncodingName => "Romanianian (Mac)";
/// <inheritdoc />
public override string HeaderName => "x-mac-romanian";
/// <inheritdoc />
public override string WebName => "x-mac-romanian";
/// <inheritdoc />
public override int WindowsCodePage => 10010;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => true;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The Mac to Unicode character map. MacRomanian is a superset of MacRomanian.</summary>
protected override char[] CharTable => new[]
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
// 0x10
'\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017',
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
// 0x80
'\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8',
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
// 0x98
'\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC',
// 0xA0
'\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF',
// 0xA8
'\u00AE', '\u00A9', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u0102', '\u0218',
// 0xB0
'\u221E', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u2202', '\u2211',
// 0xB8
'\u220F', '\u03C0', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u0103', '\u0219',
// 0xC0
'\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB',
// 0xC8
'\u00BB', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153',
// 0xD0
'\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA',
// 0xD8
'\u00FF', '\u0178', '\u2044', '\u20AC', '\u2039', '\u203A', '\u021A', '\u021B',
// 0xE0
'\u2021', '\u00B7', '\u201A', '\u201E', '\u2030', '\u00C2', '\u00CA', '\u00C1',
// 0xE8
'\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4',
// 0xF0
'\uF8FF', '\u00D2', '\u00DA', '\u00DB', '\u00D9', '\u0131', '\u02C6', '\u02DC',
// 0xF8
'\u00AF', '\u02D8', '\u02D9', '\u02DA', '\u00B8', '\u02DD', '\u02DB', '\u02C7'
};
/// <summary>Converts a Unicode character to an MacRomanian character</summary>
/// <returns>MacRomanian character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(char character) => character switch
{
'\u0000' => 0x00,
'\u0001' => 0x01,
'\u0002' => 0x02,
'\u0003' => 0x03,
'\u0004' => 0x04,
'\u0005' => 0x05,
'\u0006' => 0x06,
'\u0007' => 0x07,
'\u0008' => 0x08,
'\u0009' => 0x09,
'\u000A' => 0x0A,
'\u000B' => 0x0B,
'\u000C' => 0x0C,
'\u000D' => 0x0D,
'\u000E' => 0x0E,
'\u000F' => 0x0F,
'\u0010' => 0x10,
'\u2318' => 0x11,
'\u0012' => 0x12,
'\u2713' => 0x12,
'\u0013' => 0x13,
'\u25C6' => 0x13,
'\u0014' => 0x14,
'\u0015' => 0x15,
'\u0016' => 0x16,
'\u0017' => 0x17,
'\u0018' => 0x18,
'\u0019' => 0x19,
'\u001A' => 0x1A,
'\u001B' => 0x1B,
'\u001C' => 0x1C,
'\u001D' => 0x1D,
'\u001E' => 0x1E,
'\u001F' => 0x1F,
'\u0020' => 0x20,
'\u0021' => 0x21,
'\u0022' => 0x22,
'\u0023' => 0x23,
'\u0024' => 0x24,
'\u0025' => 0x25,
'\u0026' => 0x26,
'\u0027' => 0x27,
'\u0028' => 0x28,
'\u0029' => 0x29,
'\u002A' => 0x2A,
'\u002B' => 0x2B,
'\u002C' => 0x2C,
'\u002D' => 0x2D,
'\u002E' => 0x2E,
'\u002F' => 0x2F,
'\u0030' => 0x30,
'\u0031' => 0x31,
'\u0032' => 0x32,
'\u0033' => 0x33,
'\u0034' => 0x34,
'\u0035' => 0x35,
'\u0036' => 0x36,
'\u0037' => 0x37,
'\u0038' => 0x38,
'\u0039' => 0x39,
'\u003A' => 0x3A,
'\u003B' => 0x3B,
'\u003C' => 0x3C,
'\u003D' => 0x3D,
'\u003E' => 0x3E,
'\u003F' => 0x3F,
'\u0040' => 0x40,
'\u0041' => 0x41,
'\u0042' => 0x42,
'\u0043' => 0x43,
'\u0044' => 0x44,
'\u0045' => 0x45,
'\u0046' => 0x46,
'\u0047' => 0x47,
'\u0048' => 0x48,
'\u0049' => 0x49,
'\u004A' => 0x4A,
'\u004B' => 0x4B,
'\u004C' => 0x4C,
'\u004D' => 0x4D,
'\u004E' => 0x4E,
'\u004F' => 0x4F,
'\u0050' => 0x50,
'\u0051' => 0x51,
'\u0052' => 0x52,
'\u0053' => 0x53,
'\u0054' => 0x54,
'\u0055' => 0x55,
'\u0056' => 0x56,
'\u0057' => 0x57,
'\u0058' => 0x58,
'\u0059' => 0x59,
'\u005A' => 0x5A,
'\u005B' => 0x5B,
'\u005C' => 0x5C,
'\u005D' => 0x5D,
'\u005E' => 0x5E,
'\u005F' => 0x5F,
'\u0060' => 0x60,
'\u0061' => 0x61,
'\u0062' => 0x62,
'\u0063' => 0x63,
'\u0064' => 0x64,
'\u0065' => 0x65,
'\u0066' => 0x66,
'\u0067' => 0x67,
'\u0068' => 0x68,
'\u0069' => 0x69,
'\u006A' => 0x6A,
'\u006B' => 0x6B,
'\u006C' => 0x6C,
'\u006D' => 0x6D,
'\u006E' => 0x6E,
'\u006F' => 0x6F,
'\u0070' => 0x70,
'\u0071' => 0x71,
'\u0072' => 0x72,
'\u0073' => 0x73,
'\u0074' => 0x74,
'\u0075' => 0x75,
'\u0076' => 0x76,
'\u0077' => 0x77,
'\u0078' => 0x78,
'\u0079' => 0x79,
'\u007A' => 0x7A,
'\u007B' => 0x7B,
'\u007C' => 0x7C,
'\u007D' => 0x7D,
'\u007E' => 0x7E,
'\u007F' => 0x7F,
'\u00C4' => 0x80,
'\u00C5' => 0x81,
'\u00C7' => 0x82,
'\u00C9' => 0x83,
'\u00D1' => 0x84,
'\u00D6' => 0x85,
'\u00DC' => 0x86,
'\u00E1' => 0x87,
'\u00E0' => 0x88,
'\u00E2' => 0x89,
'\u00E4' => 0x8A,
'\u00E3' => 0x8B,
'\u00E5' => 0x8C,
'\u00E7' => 0x8D,
'\u00E9' => 0x8E,
'\u00E8' => 0x8F,
'\u00EA' => 0x90,
'\u00EB' => 0x91,
'\u00ED' => 0x92,
'\u00EC' => 0x93,
'\u00EE' => 0x94,
'\u00EF' => 0x95,
'\u00F1' => 0x96,
'\u00F3' => 0x97,
'\u00F2' => 0x98,
'\u00F4' => 0x99,
'\u00F6' => 0x9A,
'\u00F5' => 0x9B,
'\u00FA' => 0x9C,
'\u00F9' => 0x9D,
'\u00FB' => 0x9E,
'\u00FC' => 0x9F,
'\u2020' => 0xA0,
'\u00B0' => 0xA1,
'\u00A2' => 0xA2,
'\u00A3' => 0xA3,
'\u00A7' => 0xA4,
'\u2022' => 0xA5,
'\u00B6' => 0xA6,
'\u00DF' => 0xA7,
'\u00AE' => 0xA8,
'\u00A9' => 0xA9,
'\u2122' => 0xAA,
'\u00B4' => 0xAB,
'\u00A8' => 0xAC,
'\u2260' => 0xAD,
'\u0102' => 0xAE,
'\u0218' => 0xAF,
'\u221E' => 0xB0,
'\u00B1' => 0xB1,
'\u2264' => 0xB2,
'\u2265' => 0xB3,
'\u00A5' => 0xB4,
'\u00B5' => 0xB5,
'\u2202' => 0xB6,
'\u2211' => 0xB7,
'\u220F' => 0xB8,
'\u03C0' => 0xB9,
'\u222B' => 0xBA,
'\u00AA' => 0xBB,
'\u00BA' => 0xBC,
'\u03A9' => 0xBD,
'\u0103' => 0xBE,
'\u0219' => 0xBF,
'\u00BF' => 0xC0,
'\u00A1' => 0xC1,
'\u00AC' => 0xC2,
'\u221A' => 0xC3,
'\u0192' => 0xC4,
'\u2248' => 0xC5,
'\u2206' => 0xC6,
'\u00AB' => 0xC7,
'\u00BB' => 0xC8,
'\u2026' => 0xC9,
'\u00A0' => 0xCA,
'\u00C0' => 0xCB,
'\u00C3' => 0xCC,
'\u00D5' => 0xCD,
'\u0152' => 0xCE,
'\u0153' => 0xCF,
'\u2013' => 0xD0,
'\u2014' => 0xD1,
'\u201C' => 0xD2,
'\u201D' => 0xD3,
'\u2018' => 0xD4,
'\u2019' => 0xD5,
'\u00F7' => 0xD6,
'\u25CA' => 0xD7,
'\u00FF' => 0xD8,
'\u0178' => 0xD9,
'\u2044' => 0xDA,
'\u20AC' => 0xDB,
'\u2039' => 0xDC,
'\u203A' => 0xDD,
'\u021A' => 0xDE,
'\u021B' => 0xDF,
'\u2021' => 0xE0,
'\u00B7' => 0xE1,
'\u201A' => 0xE2,
'\u201E' => 0xE3,
'\u2030' => 0xE4,
'\u00C2' => 0xE5,
'\u00CA' => 0xE6,
'\u00C1' => 0xE7,
'\u00CB' => 0xE8,
'\u00C8' => 0xE9,
'\u00CD' => 0xEA,
'\u00CE' => 0xEB,
'\u00CF' => 0xEC,
'\u00CC' => 0xED,
'\u00D3' => 0xEE,
'\u00D4' => 0xEF,
'\uF8FF' => 0xF0,
'\u00D2' => 0xF1,
'\u00DA' => 0xF2,
'\u00DB' => 0xF3,
'\u00D9' => 0xF4,
'\u0131' => 0xF5,
'\u02C6' => 0xF6,
'\u02DC' => 0xF7,
'\u00AF' => 0xF8,
'\u02D8' => 0xF9,
'\u02D9' => 0xFA,
'\u02DA' => 0xFB,
'\u00B8' => 0xFC,
'\u02DD' => 0xFD,
'\u02DB' => 0xFE,
'\u02C7' => 0xFF,
_ => 0x3F
};
}

View File

@@ -0,0 +1,423 @@
//
// AtariST.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents an Mac Turkish character encoding of Unicode characters.</summary>
public class MacTurkish : SingleByteEncoding
{
/// <inheritdoc />
public override string BodyName => "x-mac-turkish";
/// <inheritdoc />
public override int CodePage => 10081;
/// <inheritdoc />
public override string EncodingName => "Turkish (Mac)";
/// <inheritdoc />
public override string HeaderName => "x-mac-turkish";
/// <inheritdoc />
public override string WebName => "x-mac-turkish";
/// <inheritdoc />
public override int WindowsCodePage => 10081;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => true;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The Macintosh Turkish to Unicode character map.</summary>
protected override char[] CharTable => new[]
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
// 0x10
'\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017',
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
// 0x80
'\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8',
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
// 0x98
'\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC',
// 0xA0
'\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF',
// 0xA8
'\u00AE', '\u00A9', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u00C6', '\u00D8',
// 0xB0
'\u221E', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u2202', '\u2211',
// 0xB8
'\u220F', '\u03C0', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u00E6', '\u00F8',
// 0xC0
'\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB',
// 0xC8
'\u00BB', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153',
// 0xD0
'\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA',
// 0xD8
'\u00FF', '\u0178', '\u011E', '\u011F', '\u0130', '\u0131', '\u015E', '\u015F',
// 0xE0
'\u2021', '\u00B7', '\u201A', '\u201E', '\u2030', '\u00C2', '\u00CA', '\u00C1',
// 0xE8
'\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4',
// 0xF0
'\uF8FF', '\u00D2', '\u00DA', '\u00D8', '\u00D9', '\uF8A0', '\u02C6', '\u02DC',
// 0xF8
'\u00AF', '\u02D8', '\u02D9', '\u02DA', '\u00B8', '\u02DD', '\u02DB', '\u02C7'
};
/// <summary>Converts a Unicode character to an Mac Turkish character</summary>
/// <returns>Mac Turkish character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(char character) => character switch
{
'\u0000' => 0x00,
'\u0001' => 0x01,
'\u0002' => 0x02,
'\u0003' => 0x03,
'\u0004' => 0x04,
'\u0005' => 0x05,
'\u0006' => 0x06,
'\u0007' => 0x07,
'\u0008' => 0x08,
'\u0009' => 0x09,
'\u000A' => 0x0A,
'\u000B' => 0x0B,
'\u000C' => 0x0C,
'\u000D' => 0x0D,
'\u000E' => 0x0E,
'\u000F' => 0x0F,
'\u0010' => 0x10,
'\u2318' => 0x11,
'\u0012' => 0x12,
'\u2713' => 0x12,
'\u0013' => 0x13,
'\u25C6' => 0x13,
'\u0014' => 0x14,
'\u0015' => 0x15,
'\u0016' => 0x16,
'\u0017' => 0x17,
'\u0018' => 0x18,
'\u0019' => 0x19,
'\u001A' => 0x1A,
'\u001B' => 0x1B,
'\u001C' => 0x1C,
'\u001D' => 0x1D,
'\u001E' => 0x1E,
'\u001F' => 0x1F,
'\u0020' => 0x20,
'\u0021' => 0x21,
'\u0022' => 0x22,
'\u0023' => 0x23,
'\u0024' => 0x24,
'\u0025' => 0x25,
'\u0026' => 0x26,
'\u0027' => 0x27,
'\u0028' => 0x28,
'\u0029' => 0x29,
'\u002A' => 0x2A,
'\u002B' => 0x2B,
'\u002C' => 0x2C,
'\u002D' => 0x2D,
'\u002E' => 0x2E,
'\u002F' => 0x2F,
'\u0030' => 0x30,
'\u0031' => 0x31,
'\u0032' => 0x32,
'\u0033' => 0x33,
'\u0034' => 0x34,
'\u0035' => 0x35,
'\u0036' => 0x36,
'\u0037' => 0x37,
'\u0038' => 0x38,
'\u0039' => 0x39,
'\u003A' => 0x3A,
'\u003B' => 0x3B,
'\u003C' => 0x3C,
'\u003D' => 0x3D,
'\u003E' => 0x3E,
'\u003F' => 0x3F,
'\u0040' => 0x40,
'\u0041' => 0x41,
'\u0042' => 0x42,
'\u0043' => 0x43,
'\u0044' => 0x44,
'\u0045' => 0x45,
'\u0046' => 0x46,
'\u0047' => 0x47,
'\u0048' => 0x48,
'\u0049' => 0x49,
'\u004A' => 0x4A,
'\u004B' => 0x4B,
'\u004C' => 0x4C,
'\u004D' => 0x4D,
'\u004E' => 0x4E,
'\u004F' => 0x4F,
'\u0050' => 0x50,
'\u0051' => 0x51,
'\u0052' => 0x52,
'\u0053' => 0x53,
'\u0054' => 0x54,
'\u0055' => 0x55,
'\u0056' => 0x56,
'\u0057' => 0x57,
'\u0058' => 0x58,
'\u0059' => 0x59,
'\u005A' => 0x5A,
'\u005B' => 0x5B,
'\u005C' => 0x5C,
'\u005D' => 0x5D,
'\u005E' => 0x5E,
'\u005F' => 0x5F,
'\u0060' => 0x60,
'\u0061' => 0x61,
'\u0062' => 0x62,
'\u0063' => 0x63,
'\u0064' => 0x64,
'\u0065' => 0x65,
'\u0066' => 0x66,
'\u0067' => 0x67,
'\u0068' => 0x68,
'\u0069' => 0x69,
'\u006A' => 0x6A,
'\u006B' => 0x6B,
'\u006C' => 0x6C,
'\u006D' => 0x6D,
'\u006E' => 0x6E,
'\u006F' => 0x6F,
'\u0070' => 0x70,
'\u0071' => 0x71,
'\u0072' => 0x72,
'\u0073' => 0x73,
'\u0074' => 0x74,
'\u0075' => 0x75,
'\u0076' => 0x76,
'\u0077' => 0x77,
'\u0078' => 0x78,
'\u0079' => 0x79,
'\u007A' => 0x7A,
'\u007B' => 0x7B,
'\u007C' => 0x7C,
'\u007D' => 0x7D,
'\u007E' => 0x7E,
'\u007F' => 0x7F,
'\u00C4' => 0x80,
'\u00C5' => 0x81,
'\u00C7' => 0x82,
'\u00C9' => 0x83,
'\u00D1' => 0x84,
'\u00D6' => 0x85,
'\u00DC' => 0x86,
'\u00E1' => 0x87,
'\u00E0' => 0x88,
'\u00E2' => 0x89,
'\u00E4' => 0x8A,
'\u00E3' => 0x8B,
'\u00E5' => 0x8C,
'\u00E7' => 0x8D,
'\u00E9' => 0x8E,
'\u00E8' => 0x8F,
'\u00EA' => 0x90,
'\u00EB' => 0x91,
'\u00ED' => 0x92,
'\u00EC' => 0x93,
'\u00EE' => 0x94,
'\u00EF' => 0x95,
'\u00F1' => 0x96,
'\u00F3' => 0x97,
'\u00F2' => 0x98,
'\u00F4' => 0x99,
'\u00F6' => 0x9A,
'\u00F5' => 0x9B,
'\u00FA' => 0x9C,
'\u00F9' => 0x9D,
'\u00FB' => 0x9E,
'\u00FC' => 0x9F,
'\u2020' => 0xA0,
'\u00B0' => 0xA1,
'\u00A2' => 0xA2,
'\u00A3' => 0xA3,
'\u00A7' => 0xA4,
'\u2022' => 0xA5,
'\u00B6' => 0xA6,
'\u00DF' => 0xA7,
'\u00AE' => 0xA8,
'\u00A9' => 0xA9,
'\u2122' => 0xAA,
'\u00B4' => 0xAB,
'\u00A8' => 0xAC,
'\u2260' => 0xAD,
'\u00C6' => 0xAE,
'\u00D8' => 0xAF,
'\u221E' => 0xB0,
'\u00B1' => 0xB1,
'\u2264' => 0xB2,
'\u2265' => 0xB3,
'\u00A5' => 0xB4,
'\u00B5' => 0xB5,
'\u2202' => 0xB6,
'\u2211' => 0xB7,
'\u220F' => 0xB8,
'\u03C0' => 0xB9,
'\u222B' => 0xBA,
'\u00AA' => 0xBB,
'\u00BA' => 0xBC,
'\u03A9' => 0xBD,
'\u00E6' => 0xBE,
'\u00F8' => 0xBF,
'\u00BF' => 0xC0,
'\u00A1' => 0xC1,
'\u00AC' => 0xC2,
'\u221A' => 0xC3,
'\u0192' => 0xC4,
'\u2248' => 0xC5,
'\u2206' => 0xC6,
'\u00AB' => 0xC7,
'\u00BB' => 0xC8,
'\u2026' => 0xC9,
'\u00A0' => 0xCA,
'\u00C0' => 0xCB,
'\u00C3' => 0xCC,
'\u00D5' => 0xCD,
'\u0152' => 0xCE,
'\u0153' => 0xCF,
'\u2013' => 0xD0,
'\u2014' => 0xD1,
'\u201C' => 0xD2,
'\u201D' => 0xD3,
'\u2018' => 0xD4,
'\u2019' => 0xD5,
'\u00F7' => 0xD6,
'\u05CA' => 0xD7,
'\u00FF' => 0xD8,
'\u0178' => 0xD9,
'\u011E' => 0xDA,
'\u011F' => 0xDB,
'\u0130' => 0xDC,
'\u0131' => 0xDD,
'\u015E' => 0xDE,
'\u015F' => 0xDF,
'\u2021' => 0xE0,
'\u00B7' => 0xE1,
'\u201A' => 0xE2,
'\u201E' => 0xE3,
'\u2030' => 0xE4,
'\u00C2' => 0xE5,
'\u00CA' => 0xE6,
'\u00C1' => 0xE7,
'\u00CB' => 0xE8,
'\u00C8' => 0xE9,
'\u00CD' => 0xEA,
'\u00CE' => 0xEB,
'\u00CF' => 0xEC,
'\u00CC' => 0xED,
'\u00D3' => 0xEE,
'\u00D4' => 0xEF,
'\uF8FF' => 0xF0,
'\u00D2' => 0xF1,
'\u00DA' => 0xF2,
'\u00DB' => 0xF3,
'\u00D9' => 0xF4,
'\uF8A0' => 0xF5,
'\u02C6' => 0xF6,
'\u02DC' => 0xF7,
'\u00AF' => 0xF8,
'\u02D8' => 0xF9,
'\u02D9' => 0xFA,
'\u02DA' => 0xFB,
'\u00B8' => 0xFC,
'\u02DD' => 0xFD,
'\u02DB' => 0xFE,
'\u02C7' => 0xFF,
_ => 0x3F
};
}

View File

@@ -0,0 +1,424 @@
//
// AtariST.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace Claunia.Encoding;
/// <summary>Represents an Mac Ukrainian character encoding of Unicode characters.</summary>
public class MacUkrainian : SingleByteEncoding
{
/// <inheritdoc />
public override string BodyName => "x-mac-ukrainian";
/// <inheritdoc />
public override int CodePage => 10017;
/// <inheritdoc />
public override string EncodingName => "Ukrainian (Mac)";
/// <inheritdoc />
public override string HeaderName => "x-mac-ukrainian";
/// <inheritdoc />
public override string WebName => "x-mac-ukrainian";
/// <inheritdoc />
public override int WindowsCodePage => 10017;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => true;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The Macintosh Ukrainian to Unicode character map.</summary>
protected override char[] CharTable => new[]
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
// 0x10
'\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017',
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
// 0x80
'\u0410', '\u0411', '\u0412', '\u0413', '\u0414', '\u0415', '\u0416', '\u0417',
// 0x88
'\u0418', '\u0419', '\u041A', '\u041B', '\u041C', '\u041D', '\u041E', '\u041F',
// 0x90
'\u0420', '\u0421', '\u0422', '\u0423', '\u0424', '\u0425', '\u0426', '\u0427',
// 0x98
'\u0428', '\u0429', '\u042A', '\u042B', '\u042C', '\u042D', '\u042E', '\u042F',
// 0xA0
'\u2020', '\u00B0', '\u0490', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u0406',
// 0xA8
'\u00AE', '\u00A9', '\u2122', '\u0402', '\u0452', '\u2260', '\u0403', '\u0453',
// 0xB0
'\u221E', '\u00B1', '\u2264', '\u2265', '\u0456', '\u00B5', '\u0491', '\u0408',
// 0xB8
'\u0404', '\u0454', '\u0407', '\u0457', '\u0409', '\u0459', '\u040A', '\u045A',
// 0xC0
'\u0458', '\u0405', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB',
// 0xC8
'\u00BB', '\u2026', '\u00A0', '\u040B', '\u045B', '\u040C', '\u045C', '\u0455',
// 0xD0
'\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u201E',
// 0xD8
'\u040E', '\u045E', '\u040F', '\u045F', '\u2116', '\u0401', '\u0451', '\u044F',
// 0xE0
'\u0430', '\u0431', '\u0432', '\u0433', '\u0434', '\u0435', '\u0436', '\u0437',
// 0xE8
'\u0438', '\u0439', '\u043A', '\u043B', '\u043C', '\u043D', '\u043E', '\u043F',
// 0xF0
'\u0440', '\u0441', '\u0442', '\u0443', '\u0444', '\u0445', '\u0446', '\u0447',
// 0xF8
'\u0448', '\u0449', '\u044A', '\u044B', '\u044C', '\u044D', '\u044E', '\u20AC'
};
/// <summary>Converts a Unicode character to an Mac Ukrainian character</summary>
/// <returns>Mac Ukrainian character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(char character) => character switch
{
'\u0000' => 0x00,
'\u0001' => 0x01,
'\u0002' => 0x02,
'\u0003' => 0x03,
'\u0004' => 0x04,
'\u0005' => 0x05,
'\u0006' => 0x06,
'\u0007' => 0x07,
'\u0008' => 0x08,
'\u0009' => 0x09,
'\u000A' => 0x0A,
'\u000B' => 0x0B,
'\u000C' => 0x0C,
'\u000D' => 0x0D,
'\u000E' => 0x0E,
'\u000F' => 0x0F,
'\u0010' => 0x10,
'\u2318' => 0x11,
'\u0012' => 0x12,
'\u2713' => 0x12,
'\u0013' => 0x13,
'\u25C6' => 0x13,
'\uF8FF' => 0x13,
'\u0014' => 0x14,
'\u0015' => 0x15,
'\u0016' => 0x16,
'\u0017' => 0x17,
'\u0018' => 0x18,
'\u0019' => 0x19,
'\u001A' => 0x1A,
'\u001B' => 0x1B,
'\u001C' => 0x1C,
'\u001D' => 0x1D,
'\u001E' => 0x1E,
'\u001F' => 0x1F,
'\u0020' => 0x20,
'\u0021' => 0x21,
'\u0022' => 0x22,
'\u0023' => 0x23,
'\u0024' => 0x24,
'\u0025' => 0x25,
'\u0026' => 0x26,
'\u0027' => 0x27,
'\u0028' => 0x28,
'\u0029' => 0x29,
'\u002A' => 0x2A,
'\u002B' => 0x2B,
'\u002C' => 0x2C,
'\u002D' => 0x2D,
'\u002E' => 0x2E,
'\u002F' => 0x2F,
'\u0030' => 0x30,
'\u0031' => 0x31,
'\u0032' => 0x32,
'\u0033' => 0x33,
'\u0034' => 0x34,
'\u0035' => 0x35,
'\u0036' => 0x36,
'\u0037' => 0x37,
'\u0038' => 0x38,
'\u0039' => 0x39,
'\u003A' => 0x3A,
'\u003B' => 0x3B,
'\u003C' => 0x3C,
'\u003D' => 0x3D,
'\u003E' => 0x3E,
'\u003F' => 0x3F,
'\u0040' => 0x40,
'\u0041' => 0x41,
'\u0042' => 0x42,
'\u0043' => 0x43,
'\u0044' => 0x44,
'\u0045' => 0x45,
'\u0046' => 0x46,
'\u0047' => 0x47,
'\u0048' => 0x48,
'\u0049' => 0x49,
'\u004A' => 0x4A,
'\u004B' => 0x4B,
'\u004C' => 0x4C,
'\u004D' => 0x4D,
'\u004E' => 0x4E,
'\u004F' => 0x4F,
'\u0050' => 0x50,
'\u0051' => 0x51,
'\u0052' => 0x52,
'\u0053' => 0x53,
'\u0054' => 0x54,
'\u0055' => 0x55,
'\u0056' => 0x56,
'\u0057' => 0x57,
'\u0058' => 0x58,
'\u0059' => 0x59,
'\u005A' => 0x5A,
'\u005B' => 0x5B,
'\u005C' => 0x5C,
'\u005D' => 0x5D,
'\u005E' => 0x5E,
'\u005F' => 0x5F,
'\u0060' => 0x60,
'\u0061' => 0x61,
'\u0062' => 0x62,
'\u0063' => 0x63,
'\u0064' => 0x64,
'\u0065' => 0x65,
'\u0066' => 0x66,
'\u0067' => 0x67,
'\u0068' => 0x68,
'\u0069' => 0x69,
'\u006A' => 0x6A,
'\u006B' => 0x6B,
'\u006C' => 0x6C,
'\u006D' => 0x6D,
'\u006E' => 0x6E,
'\u006F' => 0x6F,
'\u0070' => 0x70,
'\u0071' => 0x71,
'\u0072' => 0x72,
'\u0073' => 0x73,
'\u0074' => 0x74,
'\u0075' => 0x75,
'\u0076' => 0x76,
'\u0077' => 0x77,
'\u0078' => 0x78,
'\u0079' => 0x79,
'\u007A' => 0x7A,
'\u007B' => 0x7B,
'\u007C' => 0x7C,
'\u007D' => 0x7D,
'\u007E' => 0x7E,
'\u007F' => 0x7F,
'\u0410' => 0x80,
'\u0411' => 0x81,
'\u0412' => 0x82,
'\u0413' => 0x83,
'\u0414' => 0x84,
'\u0415' => 0x85,
'\u0416' => 0x86,
'\u0417' => 0x87,
'\u0418' => 0x88,
'\u0419' => 0x89,
'\u041A' => 0x8A,
'\u041B' => 0x8B,
'\u041C' => 0x8C,
'\u041D' => 0x8D,
'\u041E' => 0x8E,
'\u041F' => 0x8F,
'\u0420' => 0x90,
'\u0421' => 0x91,
'\u0422' => 0x92,
'\u0423' => 0x93,
'\u0424' => 0x94,
'\u0425' => 0x95,
'\u0426' => 0x96,
'\u0427' => 0x97,
'\u0428' => 0x98,
'\u0429' => 0x99,
'\u042A' => 0x9A,
'\u042B' => 0x9B,
'\u042C' => 0x9C,
'\u042D' => 0x9D,
'\u042E' => 0x9E,
'\u042F' => 0x9F,
'\u2020' => 0xA0,
'\u00B0' => 0xA1,
'\u0490' => 0xA2,
'\u00A3' => 0xA3,
'\u00A7' => 0xA4,
'\u2022' => 0xA5,
'\u00B6' => 0xA6,
'\u0406' => 0xA7,
'\u00AE' => 0xA8,
'\u00A9' => 0xA9,
'\u2122' => 0xAA,
'\u0402' => 0xAB,
'\u0452' => 0xAC,
'\u2260' => 0xAD,
'\u0403' => 0xAE,
'\u0453' => 0xAF,
'\u221E' => 0xB0,
'\u00B1' => 0xB1,
'\u2264' => 0xB2,
'\u2265' => 0xB3,
'\u0456' => 0xB4,
'\u00B5' => 0xB5,
'\u0491' => 0xB6,
'\u0408' => 0xB7,
'\u0404' => 0xB8,
'\u0454' => 0xB9,
'\u0407' => 0xBA,
'\u0457' => 0xBB,
'\u0409' => 0xBC,
'\u0459' => 0xBD,
'\u040A' => 0xBE,
'\u045A' => 0xBF,
'\u0458' => 0xC0,
'\u0405' => 0xC1,
'\u00AC' => 0xC2,
'\u221A' => 0xC3,
'\u0192' => 0xC4,
'\u2248' => 0xC5,
'\u2206' => 0xC6,
'\u00AB' => 0xC7,
'\u00BB' => 0xC8,
'\u2026' => 0xC9,
'\u00A0' => 0xCA,
'\u040B' => 0xCB,
'\u045B' => 0xCC,
'\u040C' => 0xCD,
'\u045C' => 0xCE,
'\u0455' => 0xCF,
'\u2013' => 0xD0,
'\u2014' => 0xD1,
'\u201C' => 0xD2,
'\u201D' => 0xD3,
'\u2018' => 0xD4,
'\u2019' => 0xD5,
'\u00F7' => 0xD6,
'\u201E' => 0xD7,
'\u040E' => 0xD8,
'\u045E' => 0xD9,
'\u040F' => 0xDA,
'\u045F' => 0xDB,
'\u2116' => 0xDC,
'\u0401' => 0xDD,
'\u0451' => 0xDE,
'\u044F' => 0xDF,
'\u0430' => 0xE0,
'\u0431' => 0xE1,
'\u0432' => 0xE2,
'\u0433' => 0xE3,
'\u0434' => 0xE4,
'\u0435' => 0xE5,
'\u0436' => 0xE6,
'\u0437' => 0xE7,
'\u0438' => 0xE8,
'\u0439' => 0xE9,
'\u043A' => 0xEA,
'\u043B' => 0xEB,
'\u043C' => 0xEC,
'\u043D' => 0xED,
'\u043E' => 0xEE,
'\u043F' => 0xEF,
'\u0440' => 0xF0,
'\u0441' => 0xF1,
'\u0442' => 0xF2,
'\u0443' => 0xF3,
'\u0444' => 0xF4,
'\u0445' => 0xF5,
'\u0446' => 0xF6,
'\u0447' => 0xF7,
'\u0448' => 0xF8,
'\u0449' => 0xF9,
'\u044A' => 0xFA,
'\u044B' => 0xFB,
'\u044C' => 0xFC,
'\u044D' => 0xFD,
'\u044E' => 0xFE,
'\u20AC' => 0xFF,
_ => 0x3F
};
}

View File

@@ -4,7 +4,7 @@
// Author:
// Michael Drüing <darkstar@drueing.de>
//
// Copyright (c) 2016 © Michael Drüing
// Copyright © 2016-2021 Michael Drüing
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -24,563 +24,188 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Claunia.Encoding;
namespace Claunia.Encoding
/// <summary>
/// Represents an Commodore PET Standard Code for Information Interchange (aka CBM ASCII) character encoding of
/// Unicode characters.
/// </summary>
public class PETSCII : SingleByteEncodingWithRunes
{
/// <summary>
/// Represents an Commodore PET Standard Code for Information Interchange (aka CBM ASCII) character encoding of Unicode characters.
/// </summary>
public class PETSCII : System.Text.Encoding
/// <inheritdoc />
public override string BodyName => "petscii";
/// <inheritdoc />
public override int CodePage => 0;
/// <inheritdoc />
public override string EncodingName => "Commodore PET Standard Code for Information Interchange";
/// <inheritdoc />
public override string HeaderName => "petscii";
/// <inheritdoc />
public override string WebName => "";
/// <inheritdoc />
public override int WindowsCodePage => 0;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => false;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The PETSCII to Unicode character map, unshifted (default) variant.</summary>
/// <remarks>Reference used: http://style64.org/petscii/ and others.</remarks>
protected override Rune[] CharTable => new[]
{
const string _bodyname = "petscii";
const int _codepage = 0;
const string _encodingname = "PET Standard Code for Information Interchange";
const string _headername = "petscii";
const string _webname = "";
const int _windowsCodepage = 0;
const bool browserDisplay = false;
const bool browserSave = false;
const bool mailNewsDisplay = false;
const bool mailNewsSave = false;
const bool readOnly = false;
const bool singleByte = true;
/// <summary>
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
/// </summary>
public bool IsBrowserDisplay
{
get { return browserDisplay; }
}
/// <summary>
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
/// </summary>
public bool IsBrowserSave
{
get { return browserSave; }
}
/// <summary>
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
/// </summary>
public bool IsMailNewsDisplay
{
get { return mailNewsDisplay; }
}
/// <summary>
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
/// </summary>
public bool IsMailNewsSave
{
get { return mailNewsSave; }
}
/// <summary>
/// Gets a value indicating whether the current encoding is read-only.
/// </summary>
public bool IsReadOnly
{
get { return readOnly; }
}
/// <summary>
/// Gets a value indicating whether the current encoding uses single-byte code points.
/// </summary>
public bool IsSingleByte
{
get { return singleByte; }
}
/// <summary>
/// Gets the code page identifier of the current Encoding.
/// </summary>
public int CodePage
{
get { return _codepage; }
}
/// <summary>
/// Gets a name for the current encoding that can be used with mail agent body tags
/// </summary>
public string BodyName
{
get { return _bodyname; }
}
/// <summary>
/// Gets a name for the current encoding that can be used with mail agent header tags
/// </summary>
public string HeaderName
{
get { return _headername; }
}
/// <summary>
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
/// </summary>
public override string WebName
{
get { return _webname; }
}
/// <summary>
/// Gets the human-readable description of the current encoding.
/// </summary>
public string EncodingName
{
get { return _encodingname; }
}
/// <summary>
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
/// </summary>
public int WindowsCodePage
{
get { return _windowsCodepage; }
}
/// <summary>
/// Calculates the number of bytes produced by encoding the characters in the specified <see cref="string"/>.
/// </summary>
/// <returns>The number of bytes produced by encoding the specified characters.</returns>
/// <param name="s">The <see cref="string"/> containing the set of characters to encode.</param>
public override int GetByteCount(string s)
{
if (s == null)
throw new ArgumentNullException(nameof(s));
return s.Length;
}
/// <summary>
/// Calculates the number of bytes produced by encoding a set of characters from the specified character array.
/// </summary>
/// <returns>The number of bytes produced by encoding the specified characters.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="index">The index of the first character to encode.</param>
/// <param name="count">The number of characters to encode.</param>
public override int GetByteCount(char[] chars, int index, int count)
{
if (chars == null)
throw new ArgumentNullException(nameof(chars));
if (index < 0 || index >= chars.Length)
throw new ArgumentOutOfRangeException(nameof(index));
if (count < 0 || index + count > chars.Length)
throw new ArgumentOutOfRangeException(nameof(index));
return count;
}
/// <summary>
/// Calculates the number of bytes produced by encoding all the characters in the specified character array.
/// </summary>
/// <returns>The number of bytes produced by encoding all the characters in the specified character array.</returns>
/// <param name="chars">The character array containing the characters to encode.</param>
public override int GetByteCount(char[] chars)
{
if (chars == null)
throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
/// <summary>
/// Encodes a set of characters from the specified <see cref="string"/> into the specified byte array.
/// </summary>
/// <returns>The actual number of bytes written into bytes.</returns>
/// <param name="s">The <see cref="string"/> containing the set of characters to encode.</param>
/// <param name="charIndex">The index of the first character to encode.</param>
/// <param name="charCount">The number of characters to encode.</param>
/// <param name="bytes">The byte array to contain the resulting sequence of bytes.</param>
/// <param name="byteIndex">The index at which to start writing the resulting sequence of bytes.</param>
public override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
{
return GetBytes(s.ToCharArray(), charIndex, charCount, bytes, byteIndex);
}
/// <summary>
/// Encodes all the characters in the specified string into a sequence of bytes.
/// </summary>
/// <returns>A byte array containing the results of encoding the specified set of characters.</returns>
/// <param name="s">The string containing the characters to encode.</param>
public override byte[] GetBytes(string s)
{
if (s == null)
throw new ArgumentNullException(nameof(s));
return GetBytes(s.ToCharArray(), 0, s.Length);
}
/// <summary>
/// Encodes a set of characters from the specified character array into the specified byte array.
/// </summary>
/// <returns>The actual number of bytes written into bytes.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="charIndex">The index of the first character to encode.</param>
/// <param name="charCount">The number of characters to encode.</param>
/// <param name="bytes">The byte array to contain the resulting sequence of bytes.</param>
/// <param name="byteIndex">The index at which to start writing the resulting sequence of bytes.</param>
public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
{
if (chars == null)
throw new ArgumentNullException(nameof(chars));
if (bytes == null)
throw new ArgumentNullException(nameof(bytes));
if (charIndex < 0)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if (charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount));
if (byteIndex < 0)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if (charIndex >= chars.Length)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if (charCount + charIndex > chars.Length)
throw new ArgumentOutOfRangeException(nameof(charCount));
if (byteIndex >= bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if (byteIndex + charCount > bytes.Length)
throw new ArgumentException(nameof(bytes));
byte[] temp = GetBytes(chars, charIndex, charCount);
for (int i = 0; i < temp.Length; i++)
bytes[i + byteIndex] = temp[i];
return charCount;
}
/// <summary>
/// Encodes a set of characters from the specified character array into a sequence of bytes.
/// </summary>
/// <returns>A byte array containing the results of encoding the specified set of characters.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="index">The index of the first character to encode.</param>
/// <param name="count">The number of characters to encode.</param>
public override byte[] GetBytes(char[] chars, int index, int count)
{
if (chars == null)
throw new ArgumentNullException(nameof(chars));
if (index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if (count + index > chars.Length)
throw new ArgumentOutOfRangeException(nameof(count));
byte[] bytes = new byte[count];
for (int i = 0; i < count; i++)
bytes[i] = GetByte(chars[index + i]);
return bytes;
}
/// <summary>
/// Encodes all the characters in the specified character array into a sequence of bytes.
/// </summary>
/// <returns>A byte array containing the results of encoding the specified set of characters.</returns>
/// <param name="chars">The character array containing the characters to encode.</param>
public override byte[] GetBytes(char[] chars)
{
return GetBytes(chars, 0, chars.Length);
}
/// <summary>
/// Calculates the number of characters produced by decoding all the bytes in the specified byte array.
/// </summary>
/// <returns>The number of characters produced by decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
public override int GetCharCount(byte[] bytes)
{
return GetCharCount(bytes, 0, bytes.Length);
}
/// <summary>
/// Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.
/// </summary>
/// <returns>The number of characters produced by decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override int GetCharCount(byte[] bytes, int index, int count)
{
if (bytes == null)
throw new ArgumentNullException(nameof(bytes));
if (index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if (count + index > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(count));
return count;
}
/// <summary>
/// Decodes a sequence of bytes from the specified byte array into the specified character array.
/// </summary>
/// <returns>The actual number of characters written into chars.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="byteIndex">The index of the first byte to decode.</param>
/// <param name="byteCount">The number of bytes to decode.</param>
/// <param name="chars">The character array to contain the resulting set of characters.</param>
/// <param name="charIndex">The index at which to start writing the resulting set of characters.</param>
public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
{
if (bytes == null)
throw new ArgumentNullException(nameof(bytes));
if (chars == null)
throw new ArgumentNullException(nameof(chars));
if (byteIndex < 0)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if (byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount));
if (charIndex < 0)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if (byteIndex >= bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if (byteCount + byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteCount));
if (charIndex >= chars.Length)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if (charIndex + byteCount > chars.Length)
throw new ArgumentException(nameof(chars));
char[] temp = GetChars(bytes, byteIndex, byteCount);
for (int i = 0; i < temp.Length; i++)
chars[i + charIndex] = temp[i];
return byteCount;
}
/// <summary>
/// Decodes all the bytes in the specified byte array into a set of characters.
/// </summary>
/// <returns>A character array containing the results of decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
public override char[] GetChars(byte[] bytes)
{
return GetChars(bytes, 0, bytes.Length);
}
/// <summary>
/// Decodes a sequence of bytes from the specified byte array into a set of characters.
/// </summary>
/// <returns>The chars.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override char[] GetChars(byte[] bytes, int index, int count)
{
if (bytes == null)
throw new ArgumentNullException(nameof(bytes));
if (index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if (count + index > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(count));
char[] chars = new char[count];
for (int i = 0; i < count; i++)
chars[i] = GetChar(bytes[index + i]);
return chars;
}
/// <summary>
/// Calculates the maximum number of bytes produced by encoding the specified number of characters.
/// </summary>
/// <returns>The maximum number of bytes produced by encoding the specified number of characters.</returns>
/// <param name="charCount">The number of characters to encode.</param>
public override int GetMaxByteCount(int charCount)
{
if (charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
/// <summary>
/// Calculates the maximum number of characters produced by decoding the specified number of bytes.
/// </summary>
/// <returns>The maximum number of characters produced by decoding the specified number of bytes.</returns>
/// <param name="byteCount">The number of bytes to decode.</param>
public override int GetMaxCharCount(int byteCount)
{
if (byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
/// <summary>
/// Returns a sequence of bytes that specifies the encoding used.
/// </summary>
/// <returns>A byte array of length zero, as a preamble is not required.</returns>
public override byte[] GetPreamble()
{
return new byte[0];
}
/// <summary>
/// Decodes all the bytes in the specified byte array into a string.
/// </summary>
/// <returns>A string that contains the results of decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
public string GetString(byte[] bytes)
{
return GetString(bytes, 0, bytes.Length);
}
/// <summary>
/// Decodes a sequence of bytes from the specified byte array into a string.
/// </summary>
/// <returns>A string that contains the results of decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override string GetString(byte[] bytes, int index, int count)
{
return new string(GetChars(bytes, index, count));
}
/// <summary>
/// The PETSCII to Unicode character map, unshifted (default) variant.
/// </summary>
/// <remarks>Reference used: http://style64.org/petscii/ and others.</remarks>
static readonly char[] PETSCIITable = {
// 0x00
'\u0000','\u0000','\u0000','\u0003','\u0000','\u0000','\u0000','\u0000',
// 0x08
'\u0000','\u0000','\u0000','\u0000','\u0000','\u000A','\u0000','\u0000',
// 0x10
'\u0000','\u0000','\u0000','\u0000','\u0008','\u0000','\u0000','\u0000',
// 0x18
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0x20
'\u0020','\u0021','\u0022','\u0023','\u0024','\u0025','\u0026','\u0027',
// 0x28
'\u0028','\u0029','\u002A','\u002B','\u002C','\u002D','\u002E','\u002F',
// 0x30
'\u0030','\u0031','\u0032','\u0033','\u0034','\u0035','\u0036','\u0037',
// 0x38
'\u0038','\u0039','\u003A','\u003B','\u003C','\u003D','\u003E','\u003F',
// 0x40
'\u0040','\u0041','\u0042','\u0043','\u0044','\u0045','\u0046','\u0047',
// 0x48
'\u0048','\u0049','\u004A','\u004B','\u004C','\u004D','\u004E','\u004F',
// 0x50
'\u0050','\u0051','\u0052','\u0053','\u0054','\u0055','\u0056','\u0057',
// 0x58
'\u0058','\u0059','\u005A','\u005B','\u00A3','\u005D','\u2191','\u2190',
// 0x60
'\u2500','\u2660','\u2502','\u2500','\u0000','\u0000','\u0000','\u0000',
// 0x68
'\u0000','\u256E','\u2570','\u256F','\u0000','\u2572','\u2571','\u0000',
// 0x70
'\u0000','\u2022','\u0000','\u2665','\u0000','\u256D','\u2573','\u25CB',
// 0x78
'\u2663','\u0000','\u2666','\u253C','\u0000','\u2502','\u03C0','\u25E5',
// 0x80
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0x88
'\u0000','\u0000','\u0000','\u0000','\u0000','\u2028','\u0000','\u0000',
// 0x90
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0x98
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0xA0
'\u00A0','\u258C','\u2584','\u2594','\u2581','\u258E','\u2592','\u0000',
// 0xA8
'\u0000','\u25E4','\u258A','\u251C','\u2597','\u2514','\u2510','\u2582',
// 0xB0
'\u250C','\u2534','\u252C','\u2524','\u258E','\u258D','\u0000','\u0000',
// 0xB8
'\u0000','\u2583','\u0000','\u2596','\u259D','\u2518','\u2598','\u259A',
// 0xC0 (repeats 0x60 - 0x67)
'\u2500','\u2660','\u2502','\u2500','\u0000','\u0000','\u0000','\u0000',
// 0xC8 (repeats 0x68 - 0x6F)
'\u0000','\u256E','\u2570','\u256F','\u0000','\u2572','\u2571','\u0000',
// 0xD0 (repeats 0x70 - 0x77)
'\u0000','\u2022','\u0000','\u2665','\u0000','\u256D','\u2573','\u25CB',
// 0xD8 (repeats 0x78 - 0x7F)
'\u2663','\u0000','\u2666','\u253C','\u0000','\u2502','\u03C0','\u25E5',
// 0xE0 (repeats 0xA0 - 0xA7)
'\u00A0','\u258C','\u2584','\u2594','\u2581','\u258E','\u2592','\u0000',
// 0xE8 (repeats 0xA8 - 0xAF)
'\u0000','\u25E4','\u258A','\u251C','\u2597','\u2514','\u2510','\u2582',
// 0xF0 (repeats 0xB0 - 0xB7)
'\u250C','\u2534','\u252C','\u2524','\u258E','\u258D','\u0000','\u0000',
// 0xF8 (repeats 0xB8 - 0xBF)
'\u0000','\u2583','\u0000','\u2596','\u259D','\u2518','\u2598','\u259A',
};
/// <summary>
/// Converts a PETSCII character to an Unicode character
/// </summary>
/// <returns>Unicode character.</returns>
/// <param name="character">PETSCII character.</param>
static char GetChar(byte character)
{
return PETSCIITable[character];
}
/// <summary>
/// Converts a Unicode character to an PETSCII character
/// </summary>
/// <returns>PETSCII character.</returns>
/// <param name="character">Unicode character.</param>
static byte GetByte(char character)
{
if (character == 0x0000)
{
// TODO: would returning 0x00 be more correct?
return 0x3F;
}
for (int i = 0; i < 256; i++)
{
// TODO: convert this to a gigantic switch statement too?
if (PETSCIITable[i] == character)
return (byte)i;
}
// Fallback to '?'
// 0x00
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0003), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x08
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x000A),
new Rune(0x0000), new Rune(0x0000),
// 0x10
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0008), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x18
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x20
new Rune(0x0020), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025),
new Rune(0x0026), new Rune(0x0027),
// 0x28
new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D),
new Rune(0x002E), new Rune(0x002F),
// 0x30
new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035),
new Rune(0x0036), new Rune(0x0037),
// 0x38
new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D),
new Rune(0x003E), new Rune(0x003F),
// 0x40
new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045),
new Rune(0x0046), new Rune(0x0047),
// 0x48
new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D),
new Rune(0x004E), new Rune(0x004F),
// 0x50
new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055),
new Rune(0x0056), new Rune(0x0057),
// 0x58
new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x00A3), new Rune(0x005D),
new Rune(0x2191), new Rune(0x2190),
// 0x60
new Rune(0x1FB79), new Rune(0x2660), new Rune(0x1FB72), new Rune(0x1FB78), new Rune(0x1FB77), new Rune(0x1FB76),
new Rune(0x1FB7A), new Rune(0x1FB71),
// 0x68
new Rune(0x1FB74), new Rune(0x256E), new Rune(0x2570), new Rune(0x256F), new Rune(0x1FB7C), new Rune(0x2572),
new Rune(0x2571), new Rune(0x1FB7D),
// 0x70
new Rune(0x1FB7E), new Rune(0x25CF), new Rune(0x1FB7B), new Rune(0x2665), new Rune(0x1FB70), new Rune(0x256D),
new Rune(0x2573), new Rune(0x25CB),
// 0x78
new Rune(0x2663), new Rune(0x1FB75), new Rune(0x2666), new Rune(0x253C), new Rune(0x1FB8C), new Rune(0x2502),
new Rune(0x03C0), new Rune(0x25E5),
// 0x80
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x88
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x2028),
new Rune(0x0000), new Rune(0x0000),
// 0x90
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x98
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0xA0
new Rune(0x00A0), new Rune(0x258C), new Rune(0x2584), new Rune(0x2594), new Rune(0x2581), new Rune(0x258E),
new Rune(0x2592), new Rune(0x2595),
// 0xA8
new Rune(0x1FB8F), new Rune(0x25E4), new Rune(0x1FB87), new Rune(0x251C), new Rune(0x2597), new Rune(0x2514),
new Rune(0x2510), new Rune(0x2582),
// 0xB0
new Rune(0x250C), new Rune(0x2534), new Rune(0x252C), new Rune(0x2524), new Rune(0x258E), new Rune(0x258D),
new Rune(0x1FB88), new Rune(0x1FB82),
// 0xB8
new Rune(0x1FB83), new Rune(0x2583), new Rune(0x1FB7F), new Rune(0x2596), new Rune(0x259D), new Rune(0x2518),
new Rune(0x2598), new Rune(0x259A),
// 0xC0 (repeats 0x60 - 0x67)
new Rune(0x1FB79), new Rune(0x2660), new Rune(0x1FB72), new Rune(0x1FB78), new Rune(0x1FB77), new Rune(0x1FB76),
new Rune(0x1FB7A), new Rune(0x1FB71),
// 0xC8 (repeats 0x68 - 0x6F)
new Rune(0x1FB74), new Rune(0x256E), new Rune(0x2570), new Rune(0x256F), new Rune(0x1FB7C), new Rune(0x2572),
new Rune(0x2571), new Rune(0x1FB7D),
// 0xD0 (repeats 0x70 - 0x77)
new Rune(0x1FB7E), new Rune(0x25CF), new Rune(0x1FB7B), new Rune(0x2665), new Rune(0x1FB70), new Rune(0x256D),
new Rune(0x2573), new Rune(0x25CB),
// 0xD8 (repeats 0x78 - 0x7F)
new Rune(0x2663), new Rune(0x1FB75), new Rune(0x2666), new Rune(0x253C), new Rune(0x1FB8C), new Rune(0x2502),
new Rune(0x03C0), new Rune(0x25E5),
// 0xE0 (repeats 0xA0 - 0xA7)
new Rune(0x00A0), new Rune(0x258C), new Rune(0x2584), new Rune(0x2594), new Rune(0x2581), new Rune(0x258E),
new Rune(0x2592), new Rune(0x2595),
// 0xE8 (repeats 0xA8 - 0xAF)
new Rune(0x1FB8F), new Rune(0x25E4), new Rune(0x1FB87), new Rune(0x251C), new Rune(0x2597), new Rune(0x2514),
new Rune(0x2510), new Rune(0x2582),
// 0xF0 (repeats 0xB0 - 0xB7)
new Rune(0x250C), new Rune(0x2534), new Rune(0x252C), new Rune(0x2524), new Rune(0x258E), new Rune(0x258D),
new Rune(0x1FB88), new Rune(0x1FB82),
// 0xF8 (repeats 0xB8 - 0xBF)
new Rune(0x1FB83), new Rune(0x2583), new Rune(0x1FB7F), new Rune(0x2596), new Rune(0x259D), new Rune(0x2518),
new Rune(0x2598), new Rune(0x259A)
};
/// <summary>Converts a Unicode character to an PETSCII character</summary>
/// <returns>PETSCII character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(Rune character)
{
if(character.Value == 0x0000)
return 0x3F;
}
for(int i = 0; i < 256; i++)
// TODO: convert this to a gigantic switch statement too?
if(CharTable[i] == character)
return (byte)i;
// Fallback to '?'
return 0x3F;
}
}

View File

@@ -4,7 +4,7 @@
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright (c) 2016 © Claunia.com
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -23,100 +23,108 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Claunia.Encoding
{
/// <summary>
/// Class containing pangrams for several languages that can be used to test encoding.
/// </summary>
public static class Pangrams
{
/// <summary>A pangram that contains all (or most) Arabic characters.</summary>
public const string Arabic = "صِف خَلقَ خَودِ كَمِثلِ الشَمسِ إِذ بَزَغَت — يَحظى الضَجيعُ بِها نَجلاءَ مِعطارِ";
/// <summary>A pangram that contains all (or most) Azeri characters.</summary>
public const string Azeri = "Zəfər, jaketini də papağını da götür, bu axşam hava çox soyuq olacaq.";
/// <summary>A pangram that contains all (or most) Basque characters.</summary>
public const string Basque = "Vaudeville itxurako filmean, yogi ñaño bat jipoitzen dute Quebec-en, whiski truk";
/// <summary>A pangram that contains all (or most) Breton characters.</summary>
public const string Breton = "Yeched mat Jakez ! Skarzhit ar gwerennoù-mañ, kavet e vo gwin betek fin ho puhez.";
/// <summary>A pangram that contains all (or most) Bulgarian characters.</summary>
public const string Bulgarian = "Хълцащ змей плюе шофьор стигнал чуждия бивак.";
/// <summary>A pangram that contains all (or most) Catalan characters.</summary>
public const string Catalan = "«Dóna amor que seràs feliç!». Això, il·lús company geniüt, ja és un lluït rètol blavís donze kWh.";
/// <summary>A pangram that contains Traditional Chinese characters.</summary>
public const string ChineseTraditional = "視野無限廣,窗外有藍天";
/// <summary>A pangram that contains Simplified Chinese characters.</summary>
public const string ChineseSimplified = "Innovation in China 中国智造,慧及全球";
/// <summary>A pangram that contains all (or most) Croatian characters.</summary>
public const string Croatian = "Gojazni đačić s biciklom drži hmelj i finu vatu u džepu nošnje.";
/// <summary>A pangram that contains all (or most) Czech characters.</summary>
public const string Czech = "Nechť již hříšné saxofony ďáblů rozezvučí síň úděsnými tóny waltzu, tanga a quickstepu.";
/// <summary>A pangram that contains all (or most) Danish characters.</summary>
public const string Danish = "Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen Walther spillede på xylofon.";
/// <summary>A pangram that contains all (or most) Dutch characters.</summary>
public const string Dutch = "Pas wijze lynx bezag vroom het fikse aquaduct.";
/// <summary>A pangram that contains all (or most) English characters.</summary>
public const string English = "The quick brown fox jumps over the lazy dog.";
/// <summary>A pangram that contains all (or most) Esperanto characters.</summary>
public const string Esperanto = "Eble ĉiu kvazaŭ-deca fuŝĥoraĵo ĝojigos homtipon.";
/// <summary>A pangram that contains all (or most) Estonian characters.</summary>
public const string Estonian = "Põdur Zagrebi tšellomängija-följetonist Ciqo külmetas kehvas garaažis.";
/// <summary>A pangram that contains all (or most) Finnish characters.</summary>
public const string Finnish = "Fahrenheit ja Celsius yrjösivät Åsan backgammon-peliin, Volkswagenissa, daiquirin ja ZX81:n yhteisvaikutuksesta.";
/// <summary>A pangram that contains all (or most) French characters.</summary>
public const string French = "Le cœur déçu mais l'âme plutôt naïve, Louÿs rêva de crapaüter en canoë au delà des îles, près du mälströn où brûlent les novæ.";
/// <summary>A pangram that contains all (or most) Galician characters.</summary>
public const string Galician = "Necesitamos unha tipografía chuliña de cor kiwi, que lle zorregue unha labazada visual á xente.";
/// <summary>A pangram that contains all (or most) German characters.</summary>
public const string German = "Falsches Üben von Xylophonmusik quält jeden größeren Zwerg.";
/// <summary>A pangram that contains all (or most) Greek characters.</summary>
public const string Greek = "Ταχίστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός Takhístè alôpèx vaphês psèménè gè, draskelízei ypér nòthroý kynós.";
/// <summary>A pangram that contains all (or most) Hebrew characters.</summary>
public const string Hebrew = "לכן חכו לי נאם יהוה ליום קומי לעד, כי משפטי לאסף גוים לקבצי ממלכות, לשפך עליהם זעמי כל חרון אפי, כי באש קנאתי תאכל כל הארץ";
/// <summary>A pangram that contains all (or most) Hungarian characters.</summary>
public const string Hungarian = "Jó foxim és don Quijote húszwattos lámpánál ülve egy pár bűvös cipőt készít.";
/// <summary>A pangram that contains all (or most) Icelandic characters.</summary>
public const string Icelandic = "Kæmi ný öxi hér, ykist þjófum nú bæði víl og ádrepa.";
/// <summary>A pangram that contains all (or most) Irish Gaelic characters.</summary>
public const string Irish = "Ċuaiġ bé ṁórṡáċ le dlúṫspád fíorḟinn trí hata mo ḋea-ṗorcáin ḃig";
/// <summary>A pangram that contains all (or most) Japanese kanas.</summary>
public const string Japanese = "いろはにほへと ちりぬるを わかよたれそ つねならむ うゐのおくやま けふこえて あさきゆめみし ゑひもせす(ん)";
/// <summary><see cref="Japanese"/> using Kanjis</summary>
public const string JapaneseKanji = "色は匂へど 散りぬるを 我が世誰ぞ 常ならむ 有為の奥山 今日越えて 浅き夢見じ 酔ひもせず(ん)";
/// <summary>A pangram that contains all (or most) Korean characters.</summary>
public const string Korean = "키스의 고유조건은 입술끼리 만나야 하고 특별한 기술은 필요치 않다";
/// <summary>A pangram that contains all (or most) Latvian characters.</summary>
public const string Latvian = "Četri psihi faķīri vēlu vakarā zāģēja guļbūvei durvis, fonā šņācot mežam.";
/// <summary>A pangram that contains all (or most) Lithuanian characters.</summary>
public const string Lithuanian = "Įlinkdama fechtuotojo špaga sublykčiojusi pragręžė apvalų arbūzą";
/// <summary>A pangram that contains all (or most) Macedonian characters.</summary>
public const string Macedonian = "Ѕидарски пејзаж: шугав билмез со чудење џвака ќофте и кељ на туѓ цех.";
/// <summary>A pangram that contains all (or most) Norwegian characters.</summary>
public const string Norwegian = "Jeg begynte å fortære en sandwich mens jeg kjørte taxi på vei til quiz";
/// <summary>A pangram that contains all (or most) Polish characters.</summary>
public const string Polish = "Jeżu klątw, spłódź Finom część gry hańb!";
/// <summary>A pangram that contains all (or most) Portuguese characters.</summary>
public const string Portuguese = "À noite, vovô Kowalsky vê o ímã cair no pé do pingüim queixoso e vovó põe açúcar no chá de tâmaras do jabuti feliz.";
/// <summary>A pangram that contains all (or most) Romanian characters.</summary>
public const string Romanian = "Înjurând pițigăiat, zoofobul comandă vexat whisky și tequila.";
/// <summary>A pangram that contains all (or most) Russian characters.</summary>
public const string Russian = "Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства.";
/// <summary>A pangram that contains all (or most) Scottish Gaelic characters.</summary>
public const string Scottish = "Mus dfhàg Cèit-Ùna ròp Ì le ob.";
/// <summary>A pangram that contains all (or most) Serbian characters.</summary>
public const string Serbian = "Gojazni đačić s biciklom drži hmelj i finu vatu u džepu nošnje.";
/// <summary>A pangram that contains all (or most) Slovak characters.</summary>
public const string Slovak = "Kŕdeľ šťastných ďatľov učí pri ústí Váhu mĺkveho koňa obhrýzať kôru a žrať čerstvé mäso.";
/// <summary>A pangram that contains all (or most) Slovenian characters.</summary>
public const string Slovenian = "Besni dirkač iz formule žuga cehu poštarjev.";
/// <summary>A pangram that contains all (or most) Spanish characters.</summary>
public const string Spanish = "El veloz murciélago hindú comía feliz cardillo y kiwi. La cigüeña tocaba el saxofón detrás del palenque de paja.";
/// <summary>A pangram that contains all (or most) Swedish characters.</summary>
public const string Swedish = "Flygande bäckasiner söka hwila på mjuka tuvor.";
/// <summary>A pangram that contains all (or most) Turkish characters.</summary>
public const string Turkish = "Pijamalı hasta yağız şoföre çabucak güvendi.";
/// <summary>A pangram that contains all (or most) Welsh characters.</summary>
public const string Welsh = "Parciais fy jac codi baw hud llawn dŵr ger tŷ Mabon.";
}
}
namespace Claunia.Encoding;
/// <summary>Class containing pangrams for several languages that can be used to test encoding.</summary>
public static class Pangrams
{
/// <summary>A pangram that contains all (or most) Arabic characters.</summary>
public const string ARABIC = "صِف خَلقَ خَودِ كَمِثلِ الشَمسِ إِذ بَزَغَت — يَحظى الضَجيعُ بِها نَجلاءَ مِعطارِ";
/// <summary>A pangram that contains all (or most) Azeri characters.</summary>
public const string AZERI = "Zəfər, jaketini də papağını da götür, bu axşam hava çox soyuq olacaq.";
/// <summary>A pangram that contains all (or most) Basque characters.</summary>
public const string BASQUE = "Vaudeville itxurako filmean, yogi ñaño bat jipoitzen dute Quebec-en, whiski truk";
/// <summary>A pangram that contains all (or most) Breton characters.</summary>
public const string BRETON = "Yeched mat Jakez ! Skarzhit ar gwerennoù-mañ, kavet e vo gwin betek fin ho puhez.";
/// <summary>A pangram that contains all (or most) Bulgarian characters.</summary>
public const string BULGARIAN = "Хълцащ змей плюе шофьор стигнал чуждия бивак.";
/// <summary>A pangram that contains all (or most) Catalan characters.</summary>
public const string CATALAN =
"«Dóna amor que seràs feliç!». Això, il·lús company geniüt, ja és un lluït rètol blavís donze kWh.";
/// <summary>A pangram that contains Traditional Chinese characters.</summary>
public const string CHINESE_TRADITIONAL = "視野無限廣,窗外有藍天";
/// <summary>A pangram that contains Simplified Chinese characters.</summary>
public const string CHINESE_SIMPLIFIED = "Innovation in China 中国智造,慧及全球";
/// <summary>A pangram that contains all (or most) Croatian characters.</summary>
public const string CROATIAN = "Gojazni đačić s biciklom drži hmelj i finu vatu u džepu nošnje.";
/// <summary>A pangram that contains all (or most) Czech characters.</summary>
public const string CZECH =
"Nechť již hříšné saxofony ďáblů rozezvučí síň úděsnými tóny waltzu, tanga a quickstepu.";
/// <summary>A pangram that contains all (or most) Danish characters.</summary>
public const string DANISH =
"Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen Walther spillede på xylofon.";
/// <summary>A pangram that contains all (or most) Dutch characters.</summary>
public const string DUTCH = "Pas wijze lynx bezag vroom het fikse aquaduct.";
/// <summary>A pangram that contains all (or most) English characters.</summary>
public const string ENGLISH = "The quick brown fox jumps over the lazy dog.";
/// <summary>A pangram that contains all (or most) Esperanto characters.</summary>
public const string ESPERANTO = "Eble ĉiu kvazaŭ-deca fuŝĥoraĵo ĝojigos homtipon.";
/// <summary>A pangram that contains all (or most) Estonian characters.</summary>
public const string ESTONIAN = "Põdur Zagrebi tšellomängija-följetonist Ciqo külmetas kehvas garaažis.";
/// <summary>A pangram that contains all (or most) Finnish characters.</summary>
public const string FINNISH =
"Fahrenheit ja Celsius yrjösivät Åsan backgammon-peliin, Volkswagenissa, daiquirin ja ZX81:n yhteisvaikutuksesta.";
/// <summary>A pangram that contains all (or most) French characters.</summary>
public const string FRENCH =
"Le cœur déçu mais l'âme plutôt naïve, Louÿs rêva de crapaüter en canoë au delà des îles, près du mälströn où brûlent les novæ.";
/// <summary>A pangram that contains all (or most) Galician characters.</summary>
public const string GALICIAN =
"Necesitamos unha tipografía chuliña de cor kiwi, que lle zorregue unha labazada visual á xente.";
/// <summary>A pangram that contains all (or most) German characters.</summary>
public const string GERMAN = "Falsches Üben von Xylophonmusik quält jeden größeren Zwerg.";
/// <summary>A pangram that contains all (or most) Greek characters.</summary>
public const string GREEK =
"Ταχίστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός Takhístè alôpèx vaphês psèménè gè, draskelízei ypér nòthroý kynós.";
/// <summary>A pangram that contains all (or most) Hebrew characters.</summary>
public const string HEBREW =
"לכן חכו לי נאם יהוה ליום קומי לעד, כי משפטי לאסף גוים לקבצי ממלכות, לשפך עליהם זעמי כל חרון אפי, כי באש קנאתי תאכל כל הארץ";
/// <summary>A pangram that contains all (or most) Hungarian characters.</summary>
public const string HUNGARIAN = "Jó foxim és don Quijote húszwattos lámpánál ülve egy pár bűvös cipőt készít.";
/// <summary>A pangram that contains all (or most) Icelandic characters.</summary>
public const string ICELANDIC = "Kæmi ný öxi hér, ykist þjófum nú bæði víl og ádrepa.";
/// <summary>A pangram that contains all (or most) Irish Gaelic characters.</summary>
public const string IRISH = "Ċuaiġ bé ṁórṡáċ le dlúṫspád fíorḟinn trí hata mo ḋea-ṗorcáin ḃig";
/// <summary>A pangram that contains all (or most) Japanese kanas.</summary>
public const string JAPANESE = "いろはにほへと ちりぬるを わかよたれそ つねならむ うゐのおくやま けふこえて あさきゆめみし ゑひもせす(ん)";
/// <summary><see cref="JAPANESE" /> using Kanjis</summary>
public const string JAPANESE_KANJI = "色は匂へど 散りぬるを 我が世誰ぞ 常ならむ 有為の奥山 今日越えて 浅き夢見じ 酔ひもせず(ん)";
/// <summary>A pangram that contains all (or most) Korean characters.</summary>
public const string KOREAN = "키스의 고유조건은 입술끼리 만나야 하고 특별한 기술은 필요치 않다";
/// <summary>A pangram that contains all (or most) Latvian characters.</summary>
public const string LATVIAN = "Četri psihi faķīri vēlu vakarā zāģēja guļbūvei durvis, fonā šņācot mežam.";
/// <summary>A pangram that contains all (or most) Lithuanian characters.</summary>
public const string LITHUANIAN = "Įlinkdama fechtuotojo špaga sublykčiojusi pragręžė apvalų arbūzą";
/// <summary>A pangram that contains all (or most) Macedonian characters.</summary>
public const string MACEDONIAN = "Ѕидарски пејзаж: шугав билмез со чудење џвака ќофте и кељ на туѓ цех.";
/// <summary>A pangram that contains all (or most) Norwegian characters.</summary>
public const string NORWEGIAN = "Jeg begynte å fortære en sandwich mens jeg kjørte taxi på vei til quiz";
/// <summary>A pangram that contains all (or most) Polish characters.</summary>
public const string POLISH = "Jeżu klątw, spłódź Finom część gry hańb!";
/// <summary>A pangram that contains all (or most) Portuguese characters.</summary>
public const string PORTUGUESE =
"À noite, vovô Kowalsky vê o ímã cair no pé do pingüim queixoso e vovó põe açúcar no chá de tâmaras do jabuti feliz.";
/// <summary>A pangram that contains all (or most) Romanian characters.</summary>
public const string ROMANIAN = "Înjurând pițigăiat, zoofobul comandă vexat whisky și tequila.";
/// <summary>A pangram that contains all (or most) Russian characters.</summary>
public const string RUSSIAN =
"Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства.";
/// <summary>A pangram that contains all (or most) Scottish Gaelic characters.</summary>
public const string SCOTTISH = "Mus dfhàg Cèit-Ùna ròp Ì le ob.";
/// <summary>A pangram that contains all (or most) Serbian characters.</summary>
public const string SERBIAN = "Gojazni đačić s biciklom drži hmelj i finu vatu u džepu nošnje.";
/// <summary>A pangram that contains all (or most) Slovak characters.</summary>
public const string SLOVAK =
"Kŕdeľ šťastných ďatľov učí pri ústí Váhu mĺkveho koňa obhrýzať kôru a žrať čerstvé mäso.";
/// <summary>A pangram that contains all (or most) Slovenian characters.</summary>
public const string SLOVENIAN = "Besni dirkač iz formule žuga cehu poštarjev.";
/// <summary>A pangram that contains all (or most) Spanish characters.</summary>
public const string SPANISH =
"El veloz murciélago hindú comía feliz cardillo y kiwi. La cigüeña tocaba el saxofón detrás del palenque de paja.";
/// <summary>A pangram that contains all (or most) Swedish characters.</summary>
public const string SWEDISH = "Flygande bäckasiner söka hwila på mjuka tuvor.";
/// <summary>A pangram that contains all (or most) Turkish characters.</summary>
public const string TURKISH = "Pijamalı hasta yağız şoföre çabucak güvendi.";
/// <summary>A pangram that contains all (or most) Welsh characters.</summary>
public const string WELSH = "Parciais fy jac codi baw hud llawn dŵr ger tŷ Mabon.";
}

View File

@@ -1,54 +0,0 @@
//
// Author:
// Natalia Portillo claunia@claunia.com
//
// Copyright (c) 2016, © Claunia.com
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in
// the documentation and/or other materials provided with the distribution.
// * Neither the name of the [ORGANIZATION] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle ("Claunia.Encoding")]
[assembly: AssemblyDescription ("")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("Claunia.com")]
[assembly: AssemblyProduct ("")]
[assembly: AssemblyCopyright ("© Claunia.com")]
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyCulture ("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion ("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

348
Claunia.Encoding/Radix50.cs Normal file
View File

@@ -0,0 +1,348 @@
//
// Apple II.cs
//
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Claunia.Encoding;
/// <summary>Represents an Radix-50 (PDP-11) character encoding of Unicode characters.</summary>
public class Radix50 : SingleByteEncoding
{
/// <inheritdoc />
public override string BodyName => "radix50";
/// <inheritdoc />
public override int CodePage => 0;
/// <inheritdoc />
public override string EncodingName => "Western European (Radix-50)";
/// <inheritdoc />
public override string HeaderName => "radix50";
/// <inheritdoc />
public override string WebName => "";
/// <inheritdoc />
public override int WindowsCodePage => 0;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => false;
/// <inheritdoc />
public override bool IsSingleByte => false;
/// <summary>The Radix-50 to Unicode character map, when bits are shifted right</summary>
protected override char[] CharTable => new[]
{
// 0x00
'\u0020', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
// 0x08
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
// 0x10
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
// 0x18
'\u0058', '\u0059', '\u005A', '\u0024', '\u002E', '\u0025', '\u0030', '\u0031',
// 0x20
'\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', '\u0038', '\u0039',
// 0x28 (unused but legal)
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0x30 (unused but legal)
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
// 0x38 (unused but legal)
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000'
};
/// <summary>Calculates the number of bytes produced by encoding the characters in the specified <see cref="string" />.</summary>
/// <returns>The number of bytes produced by encoding the specified characters.</returns>
/// <param name="s">The <see cref="string" /> containing the set of characters to encode.</param>
public override int GetByteCount(string s)
{
if(s == null)
throw new ArgumentNullException(nameof(s));
return s.Length * 6 % 8 > 0 ? (s.Length * 6 / 8) + 1 : s.Length * 6 / 8;
}
/// <summary>Calculates the number of bytes produced by encoding a set of characters from the specified character array.</summary>
/// <returns>The number of bytes produced by encoding the specified characters.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="index">The index of the first character to encode.</param>
/// <param name="count">The number of characters to encode.</param>
public override int GetByteCount(char[] chars, int index, int count)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(index < 0 ||
index >= chars.Length)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0 ||
index + count > chars.Length)
throw new ArgumentOutOfRangeException(nameof(index));
return count * 6 % 8 > 0 ? (count * 6 / 8) + 1 : count * 6 / 8;
}
/// <summary>Calculates the number of bytes produced by encoding all the characters in the specified character array.</summary>
/// <returns>The number of bytes produced by encoding all the characters in the specified character array.</returns>
/// <param name="chars">The character array containing the characters to encode.</param>
public override int GetByteCount(char[] chars)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
return chars.Length * 6 % 8 > 0 ? (chars.Length * 6 / 8) + 1 : chars.Length * 6 / 8;
}
/// <summary>Encodes a set of characters from the specified character array into a sequence of bytes.</summary>
/// <returns>A byte array containing the results of encoding the specified set of characters.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="index">The index of the first character to encode.</param>
/// <param name="count">The number of characters to encode.</param>
public override byte[] GetBytes(char[] chars, int index, int count)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if(count + index > chars.Length)
throw new ArgumentOutOfRangeException(nameof(count));
byte[] bytes = new byte[count * 6 % 8 > 0 ? (count * 6 / 8) + 1 : count * 6 / 8];
int outPos = 0;
for(int i = 0; i < count; i++)
{
byte thisByte = GetByte(chars[index + i]);
switch(i % 4)
{
case 0:
if(outPos >= bytes.Length)
break;
bytes[outPos] = (byte)(thisByte << 2);
break;
case 1:
if(outPos + 1 >= bytes.Length)
break;
bytes[outPos] += (byte)((thisByte & 0x30) >> 4);
bytes[outPos + 1] = (byte)((thisByte & 0xF) << 4);
break;
case 2:
if(outPos + 2 >= bytes.Length)
break;
bytes[outPos + 1] += (byte)((thisByte & 0x3C) >> 2);
bytes[outPos + 2] = (byte)((thisByte & 0x3) << 6);
break;
case 3:
if(outPos + 2 >= bytes.Length)
break;
bytes[outPos + 2] += (byte)(thisByte & 0x3F);
outPos += 3;
break;
}
}
return bytes;
}
/// <summary>Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.</summary>
/// <returns>The number of characters produced by decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override int GetCharCount(byte[] bytes, int index, int count)
{
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if(count + index > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(count));
return count * 8 / 6;
}
/// <summary>Decodes a sequence of bytes from the specified byte array into a set of characters.</summary>
/// <returns>The chars.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override char[] GetChars(byte[] bytes, int index, int count)
{
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if(count + index > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(count));
char[] chars = new char[count * 8 / 6];
// aaaaaabb bbbbcccc ccdddddd
int outPos = 0;
for(int i = 0; i < count; i++)
{
byte rd50;
switch(i % 3)
{
case 0:
rd50 = (byte)((bytes[index + i] & 0xFC) >> 2);
chars[outPos] = GetChar(rd50);
outPos++;
break;
case 1:
rd50 = (byte)(((bytes[index + i - 1] & 0x03) << 4) + ((bytes[index + i] & 0xF0) >> 4));
chars[outPos] = GetChar(rd50);
outPos++;
break;
case 2:
rd50 = (byte)(((bytes[index + i - 1] & 0x0F) << 2) + ((bytes[index + i] & 0xC0) >> 6));
chars[outPos] = GetChar(rd50);
chars[outPos + 1] = GetChar((byte)(bytes[index + i] & 0x3F));
outPos += 2;
break;
}
}
return chars;
}
/// <summary>Calculates the maximum number of bytes produced by encoding the specified number of characters.</summary>
/// <returns>The maximum number of bytes produced by encoding the specified number of characters.</returns>
/// <param name="charCount">The number of characters to encode.</param>
public override int GetMaxByteCount(int charCount)
{
if(charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount * 6 % 8 > 0 ? (charCount * 6 / 8) + 1 : charCount * 6 / 8;
}
/// <summary>Calculates the maximum number of characters produced by decoding the specified number of bytes.</summary>
/// <returns>The maximum number of characters produced by decoding the specified number of bytes.</returns>
/// <param name="byteCount">The number of bytes to decode.</param>
public override int GetMaxCharCount(int byteCount)
{
if(byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount * 8 / 6;
}
/// <summary>Converts a Apple II character to an Unicode character</summary>
/// <returns>Unicode character.</returns>
/// <param name="character">Apple II character.</param>
char GetChar(byte character) => CharTable[character & 0x3F];
/// <summary>Converts a Unicode character to an Apple II character</summary>
/// <returns>Apple II character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(char character) => character switch
{
'\u0020' => 0x00,
'\u0041' => 0x01,
'\u0042' => 0x02,
'\u0043' => 0x03,
'\u0044' => 0x04,
'\u0045' => 0x05,
'\u0046' => 0x06,
'\u0047' => 0x07,
'\u0048' => 0x08,
'\u0049' => 0x09,
'\u004A' => 0x0A,
'\u004B' => 0x0B,
'\u004C' => 0x0C,
'\u004D' => 0x0D,
'\u004E' => 0x0E,
'\u004F' => 0x0F,
'\u0050' => 0x10,
'\u0051' => 0x11,
'\u0052' => 0x12,
'\u0053' => 0x13,
'\u0054' => 0x14,
'\u0055' => 0x15,
'\u0056' => 0x16,
'\u0057' => 0x17,
'\u0058' => 0x18,
'\u0059' => 0x19,
'\u005A' => 0x1A,
'\u0024' => 0x1B,
'\u002E' => 0x1C,
'\u0025' => 0x1D,
'\u0030' => 0x1E,
'\u0031' => 0x1F,
'\u0032' => 0x20,
'\u0033' => 0x21,
'\u0034' => 0x22,
'\u0035' => 0x23,
'\u0036' => 0x24,
'\u0037' => 0x25,
'\u0038' => 0x26,
'\u0039' => 0x27,
_ => 0x1C
};
}

View File

@@ -0,0 +1,338 @@
using System;
namespace Claunia.Encoding;
/// <summary>Implements a class that converts to/from a single byte codepage and UTF-16 representable strings</summary>
public abstract class SingleByteEncoding : Encoding
{
/// <summary>Character conversion table</summary>
protected abstract char[] CharTable { get; }
/// <summary>Gets a value indicating whether the current encoding can be used by browser clients for displaying content.</summary>
public abstract override bool IsBrowserDisplay { get; }
/// <summary>Gets a value indicating whether the current encoding can be used by browser clients for saving content.</summary>
public abstract override bool IsBrowserSave { get; }
/// <summary>
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
/// content.
/// </summary>
public abstract override bool IsMailNewsDisplay { get; }
/// <summary>Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.</summary>
public abstract override bool IsMailNewsSave { get; }
/// <summary>Gets a value indicating whether the current encoding is read-only.</summary>
/// <value>The is single byte.</value>
public abstract override bool IsReadOnly { get; }
/// <summary>Gets a value indicating whether the current encoding uses single-byte code points.</summary>
public abstract override bool IsSingleByte { get; }
/// <summary>Gets the code page identifier of the current Encoding.</summary>
public abstract override int CodePage { get; }
/// <summary>Gets a name for the current encoding that can be used with mail agent body tags</summary>
public abstract override string BodyName { get; }
/// <summary>Gets a name for the current encoding that can be used with mail agent header tags</summary>
public abstract override string HeaderName { get; }
/// <summary>Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.</summary>
public abstract override string WebName { get; }
/// <summary>Gets the human-readable description of the current encoding.</summary>
public abstract override string EncodingName { get; }
/// <summary>Gets the Windows operating system code page that most closely corresponds to the current encoding.</summary>
public abstract override int WindowsCodePage { get; }
/// <summary>Calculates the number of bytes produced by encoding the characters in the specified <see cref="string" />.</summary>
/// <returns>The number of bytes produced by encoding the specified characters.</returns>
/// <param name="s">The <see cref="string" /> containing the set of characters to encode.</param>
public override int GetByteCount(string s)
{
if(s == null)
throw new ArgumentNullException(nameof(s));
return s.Length;
}
/// <summary>Calculates the number of bytes produced by encoding a set of characters from the specified character array.</summary>
/// <returns>The number of bytes produced by encoding the specified characters.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="index">The index of the first character to encode.</param>
/// <param name="count">The number of characters to encode.</param>
public override int GetByteCount(char[] chars, int index, int count)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(index < 0 ||
index >= chars.Length)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0 ||
index + count > chars.Length)
throw new ArgumentOutOfRangeException(nameof(index));
return count;
}
/// <summary>Calculates the number of bytes produced by encoding all the characters in the specified character array.</summary>
/// <returns>The number of bytes produced by encoding all the characters in the specified character array.</returns>
/// <param name="chars">The character array containing the characters to encode.</param>
public override int GetByteCount(char[] chars)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
/// <summary>Encodes a set of characters from the specified <see cref="string" /> into the specified byte array.</summary>
/// <returns>The actual number of bytes written into bytes.</returns>
/// <param name="s">The <see cref="string" /> containing the set of characters to encode.</param>
/// <param name="charIndex">The index of the first character to encode.</param>
/// <param name="charCount">The number of characters to encode.</param>
/// <param name="bytes">The byte array to contain the resulting sequence of bytes.</param>
/// <param name="byteIndex">The index at which to start writing the resulting sequence of bytes.</param>
public override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex) =>
GetBytes(s.ToCharArray(), charIndex, charCount, bytes, byteIndex);
/// <summary>Encodes all the characters in the specified string into a sequence of bytes.</summary>
/// <returns>A byte array containing the results of encoding the specified set of characters.</returns>
/// <param name="s">The string containing the characters to encode.</param>
public override byte[] GetBytes(string s)
{
if(s == null)
throw new ArgumentNullException(nameof(s));
return GetBytes(s.ToCharArray(), 0, s.Length);
}
/// <summary>Encodes a set of characters from the specified character array into the specified byte array.</summary>
/// <returns>The actual number of bytes written into bytes.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="charIndex">The index of the first character to encode.</param>
/// <param name="charCount">The number of characters to encode.</param>
/// <param name="bytes">The byte array to contain the resulting sequence of bytes.</param>
/// <param name="byteIndex">The index at which to start writing the resulting sequence of bytes.</param>
public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(charIndex < 0)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if(charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount));
if(byteIndex < 0)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if(charIndex >= chars.Length)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if(charCount + charIndex > chars.Length)
throw new ArgumentOutOfRangeException(nameof(charCount));
if(byteIndex >= bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if(byteIndex + charCount > bytes.Length)
throw new ArgumentException(nameof(bytes));
byte[] temp = GetBytes(chars, charIndex, charCount);
for(int i = 0; i < temp.Length; i++)
bytes[i + byteIndex] = temp[i];
return charCount;
}
/// <summary>Encodes a set of characters from the specified character array into a sequence of bytes.</summary>
/// <returns>A byte array containing the results of encoding the specified set of characters.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="index">The index of the first character to encode.</param>
/// <param name="count">The number of characters to encode.</param>
public override byte[] GetBytes(char[] chars, int index, int count)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if(count + index > chars.Length)
throw new ArgumentOutOfRangeException(nameof(count));
byte[] bytes = new byte[count];
for(int i = 0; i < count; i++)
bytes[i] = GetByte(chars[index + i]);
return bytes;
}
/// <summary>Encodes all the characters in the specified character array into a sequence of bytes.</summary>
/// <returns>A byte array containing the results of encoding the specified set of characters.</returns>
/// <param name="chars">The character array containing the characters to encode.</param>
public override byte[] GetBytes(char[] chars) => GetBytes(chars, 0, chars.Length);
/// <summary>Calculates the number of characters produced by decoding all the bytes in the specified byte array.</summary>
/// <returns>The number of characters produced by decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
public override int GetCharCount(byte[] bytes) => GetCharCount(bytes, 0, bytes.Length);
/// <summary>Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.</summary>
/// <returns>The number of characters produced by decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override int GetCharCount(byte[] bytes, int index, int count)
{
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if(count + index > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(count));
return count;
}
/// <summary>Decodes a sequence of bytes from the specified byte array into the specified character array.</summary>
/// <returns>The actual number of characters written into chars.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="byteIndex">The index of the first byte to decode.</param>
/// <param name="byteCount">The number of bytes to decode.</param>
/// <param name="chars">The character array to contain the resulting set of characters.</param>
/// <param name="charIndex">The index at which to start writing the resulting set of characters.</param>
public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
{
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(byteIndex < 0)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if(byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount));
if(charIndex < 0)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if(byteIndex >= bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if(byteCount + byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteCount));
if(charIndex >= chars.Length)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if(charIndex + byteCount > chars.Length)
throw new ArgumentException(nameof(chars));
char[] temp = GetChars(bytes, byteIndex, byteCount);
for(int i = 0; i < temp.Length; i++)
chars[i + charIndex] = temp[i];
return byteCount;
}
/// <summary>Decodes all the bytes in the specified byte array into a set of characters.</summary>
/// <returns>A character array containing the results of decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
public override char[] GetChars(byte[] bytes) => GetChars(bytes, 0, bytes.Length);
/// <summary>Decodes a sequence of bytes from the specified byte array into a set of characters.</summary>
/// <returns>The chars.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override char[] GetChars(byte[] bytes, int index, int count)
{
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if(count + index > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(count));
char[] chars = new char[count];
for(int i = 0; i < count; i++)
chars[i] = GetChar(bytes[index + i]);
return chars;
}
/// <summary>Calculates the maximum number of bytes produced by encoding the specified number of characters.</summary>
/// <returns>The maximum number of bytes produced by encoding the specified number of characters.</returns>
/// <param name="charCount">The number of characters to encode.</param>
public override int GetMaxByteCount(int charCount)
{
if(charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
/// <summary>Calculates the maximum number of characters produced by decoding the specified number of bytes.</summary>
/// <returns>The maximum number of characters produced by decoding the specified number of bytes.</returns>
/// <param name="byteCount">The number of bytes to decode.</param>
public override int GetMaxCharCount(int byteCount)
{
if(byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
/// <summary>Returns a sequence of bytes that specifies the encoding used.</summary>
/// <returns>A byte array of length zero, as a preamble is not required.</returns>
public override byte[] GetPreamble() => new byte[0];
/// <summary>Decodes all the bytes in the specified byte array into a string.</summary>
/// <returns>A string that contains the results of decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
public override string GetString(byte[] bytes) => GetString(bytes, 0, bytes.Length);
/// <summary>Decodes a sequence of bytes from the specified byte array into a string.</summary>
/// <returns>A string that contains the results of decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
/// <summary>Converts a codepage character to an Unicode character</summary>
/// <returns>Unicode character.</returns>
/// <param name="character">Codepage character.</param>
char GetChar(byte character) => CharTable[character];
private protected abstract byte GetByte(char character);
}

View File

@@ -0,0 +1,370 @@
using System;
using System.Globalization;
using System.Linq;
namespace Claunia.Encoding;
/// <summary>
/// Implements a class that converts to/from a single byte codepage and strings that contains elements that need
/// surrogates in UTF-16, using runes.
/// </summary>
public abstract class SingleByteEncodingWithRunes : Encoding
{
/// <summary>Rune conversion table</summary>
protected abstract Rune[] CharTable { get; }
/// <summary>Gets a value indicating whether the current encoding can be used by browser clients for displaying content.</summary>
public abstract override bool IsBrowserDisplay { get; }
/// <summary>Gets a value indicating whether the current encoding can be used by browser clients for saving content.</summary>
public abstract override bool IsBrowserSave { get; }
/// <summary>
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
/// content.
/// </summary>
public abstract override bool IsMailNewsDisplay { get; }
/// <summary>Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.</summary>
public abstract override bool IsMailNewsSave { get; }
/// <summary>Gets a value indicating whether the current encoding is read-only.</summary>
/// <value>The is single byte.</value>
public abstract override bool IsReadOnly { get; }
/// <summary>Gets a value indicating whether the current encoding uses single-byte code points.</summary>
public abstract override bool IsSingleByte { get; }
/// <summary>Gets the code page identifier of the current Encoding.</summary>
public abstract override int CodePage { get; }
/// <summary>Gets a name for the current encoding that can be used with mail agent body tags</summary>
public abstract override string BodyName { get; }
/// <summary>Gets a name for the current encoding that can be used with mail agent header tags</summary>
public abstract override string HeaderName { get; }
/// <summary>Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.</summary>
public abstract override string WebName { get; }
/// <summary>Gets the human-readable description of the current encoding.</summary>
public abstract override string EncodingName { get; }
/// <summary>Gets the Windows operating system code page that most closely corresponds to the current encoding.</summary>
public abstract override int WindowsCodePage { get; }
/// <summary>Calculates the number of bytes produced by encoding the characters in the specified <see cref="string" />.</summary>
/// <returns>The number of bytes produced by encoding the specified characters.</returns>
/// <param name="s">The <see cref="string" /> containing the set of characters to encode.</param>
public override int GetByteCount(string s)
{
if(s == null)
throw new ArgumentNullException(nameof(s));
return new StringInfo(s).LengthInTextElements;
}
/// <summary>Calculates the number of bytes produced by encoding a set of characters from the specified character array.</summary>
/// <returns>The number of bytes produced by encoding the specified characters.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="index">The index of the first character to encode.</param>
/// <param name="count">The number of characters to encode.</param>
public override int GetByteCount(char[] chars, int index, int count)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(index < 0 ||
index >= chars.Length)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0 ||
index + count > chars.Length)
throw new ArgumentOutOfRangeException(nameof(index));
return new StringInfo(new string(chars, index, count)).LengthInTextElements;
}
/// <summary>Calculates the number of bytes produced by encoding all the characters in the specified character array.</summary>
/// <returns>The number of bytes produced by encoding all the characters in the specified character array.</returns>
/// <param name="chars">The character array containing the characters to encode.</param>
public override int GetByteCount(char[] chars)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
return new StringInfo(new string(chars)).LengthInTextElements;
}
/// <summary>Encodes a set of characters from the specified <see cref="string" /> into the specified byte array.</summary>
/// <returns>The actual number of bytes written into bytes.</returns>
/// <param name="s">The <see cref="string" /> containing the set of characters to encode.</param>
/// <param name="charIndex">The index of the first character to encode.</param>
/// <param name="charCount">The number of characters to encode.</param>
/// <param name="bytes">The byte array to contain the resulting sequence of bytes.</param>
/// <param name="byteIndex">The index at which to start writing the resulting sequence of bytes.</param>
public override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex) =>
GetBytes(s.ToCharArray(), charIndex, charCount, bytes, byteIndex);
/// <summary>Encodes all the characters in the specified string into a sequence of bytes.</summary>
/// <returns>A byte array containing the results of encoding the specified set of characters.</returns>
/// <param name="s">The string containing the characters to encode.</param>
public override byte[] GetBytes(string s)
{
if(s == null)
throw new ArgumentNullException(nameof(s));
return GetBytes(s.ToCharArray(), 0, new StringInfo(s).LengthInTextElements);
}
/// <summary>Encodes a set of characters from the specified character array into the specified byte array.</summary>
/// <returns>The actual number of bytes written into bytes.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="charIndex">The index of the first character to encode.</param>
/// <param name="charCount">The number of characters to encode.</param>
/// <param name="bytes">The byte array to contain the resulting sequence of bytes.</param>
/// <param name="byteIndex">The index at which to start writing the resulting sequence of bytes.</param>
public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(charIndex < 0)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if(charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount));
if(byteIndex < 0)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if(charIndex >= chars.Length)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if(charCount + charIndex > chars.Length)
throw new ArgumentOutOfRangeException(nameof(charCount));
if(byteIndex >= bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if(byteIndex + charCount > bytes.Length)
throw new ArgumentException(nameof(bytes));
byte[] temp = GetBytes(chars, charIndex, charCount);
for(int i = 0; i < temp.Length; i++)
bytes[i + byteIndex] = temp[i];
return charCount;
}
/// <summary>Encodes a set of characters from the specified character array into a sequence of bytes.</summary>
/// <returns>A byte array containing the results of encoding the specified set of characters.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="index">The index of the first character to encode.</param>
/// <param name="count">The number of characters to encode.</param>
public override byte[] GetBytes(char[] chars, int index, int count)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
string s = new(chars);
if(count + index > new StringInfo(s).LengthInTextElements)
throw new ArgumentOutOfRangeException(nameof(count));
byte[] bytes = new byte[count];
StringRuneEnumerator runes = s.EnumerateRunes();
runes.MoveNext();
for(int i = 0; i < index; i++)
{
if(!runes.MoveNext())
throw new ArgumentOutOfRangeException(nameof(index));
}
bool finished = false;
for(int i = 0; i < count; i++)
{
if(finished)
throw new ArgumentOutOfRangeException(nameof(count));
bytes[i] = GetByte(runes.Current);
finished = !runes.MoveNext();
}
return bytes;
}
/// <summary>Encodes all the characters in the specified character array into a sequence of bytes.</summary>
/// <returns>A byte array containing the results of encoding the specified set of characters.</returns>
/// <param name="chars">The character array containing the characters to encode.</param>
public override byte[] GetBytes(char[] chars) => GetBytes(chars, 0, chars.Length);
/// <summary>Calculates the number of characters produced by decoding all the bytes in the specified byte array.</summary>
/// <returns>The number of characters produced by decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
public override int GetCharCount(byte[] bytes) => GetCharCount(bytes, 0, bytes.Length);
/// <summary>Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.</summary>
/// <returns>The number of characters produced by decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override int GetCharCount(byte[] bytes, int index, int count)
{
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if(count + index > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(count));
return count;
}
/// <summary>Decodes a sequence of bytes from the specified byte array into the specified character array.</summary>
/// <returns>The actual number of characters written into chars.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="byteIndex">The index of the first byte to decode.</param>
/// <param name="byteCount">The number of bytes to decode.</param>
/// <param name="chars">The character array to contain the resulting set of characters.</param>
/// <param name="charIndex">The index at which to start writing the resulting set of characters.</param>
public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
{
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(byteIndex < 0)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if(byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount));
if(charIndex < 0)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if(byteIndex >= bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if(byteCount + byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteCount));
if(charIndex >= chars.Length)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if(charIndex + byteCount > chars.Length)
throw new ArgumentException(nameof(chars));
char[] temp = GetChars(bytes, byteIndex, byteCount);
for(int i = 0; i < temp.Length; i++)
chars[i + charIndex] = temp[i];
return byteCount;
}
/// <summary>Decodes all the bytes in the specified byte array into a set of characters.</summary>
/// <returns>A character array containing the results of decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
public override char[] GetChars(byte[] bytes) => GetChars(bytes, 0, bytes.Length);
/// <summary>Decodes a sequence of bytes from the specified byte array into a set of characters.</summary>
/// <returns>The chars.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override char[] GetChars(byte[] bytes, int index, int count) => GetString(bytes, index, count).ToCharArray();
/// <summary>Calculates the maximum number of bytes produced by encoding the specified number of characters.</summary>
/// <returns>The maximum number of bytes produced by encoding the specified number of characters.</returns>
/// <param name="charCount">The number of characters to encode.</param>
public override int GetMaxByteCount(int charCount)
{
if(charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
/// <summary>Calculates the maximum number of characters produced by decoding the specified number of bytes.</summary>
/// <returns>The maximum number of characters produced by decoding the specified number of bytes.</returns>
/// <param name="byteCount">The number of bytes to decode.</param>
public override int GetMaxCharCount(int byteCount)
{
if(byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
/// <summary>Returns a sequence of bytes that specifies the encoding used.</summary>
/// <returns>A byte array of length zero, as a preamble is not required.</returns>
public override byte[] GetPreamble() => new byte[0];
/// <summary>Decodes all the bytes in the specified byte array into a string.</summary>
/// <returns>A string that contains the results of decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
public override string GetString(byte[] bytes) => GetString(bytes, 0, bytes.Length);
/// <summary>Decodes a sequence of bytes from the specified byte array into a string.</summary>
/// <returns>A string that contains the results of decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override string GetString(byte[] bytes, int index, int count)
{
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if(count + index > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(count));
Rune[] runes = new Rune[count];
for(int i = 0; i < count; i++)
runes[i] = GetChar(bytes[index + i]);
char[] chars = new char[runes.Select(r => r.Utf16SequenceLength).Sum()];
int outPos = 0;
foreach(Rune r in runes)
outPos += r.EncodeToUtf16(new Span<char>(chars, outPos, chars.Length - outPos));
return new string(chars);
}
/// <summary>Converts a codepage character to an Unicode character</summary>
/// <returns>Unicode character.</returns>
/// <param name="character">Codepage character.</param>
Rune GetChar(byte character) => CharTable[character];
private protected abstract byte GetByte(Rune character);
}

View File

@@ -4,7 +4,7 @@
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright (c) 2016 © Claunia.com
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -24,687 +24,252 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Claunia.Encoding;
namespace Claunia.Encoding
/// <summary>Represents a ZX80 character encoding of Unicode characters.</summary>
public class ZX80 : SingleByteEncodingWithRunes
{
/// <summary>
/// Represents a ZX80 character encoding of Unicode characters.
/// </summary>
public class ZX80 : System.Text.Encoding
/// <inheritdoc />
public override string BodyName => "zx80";
/// <inheritdoc />
public override int CodePage => 0;
/// <inheritdoc />
public override string EncodingName => "Sinclair ZX80 character set";
/// <inheritdoc />
public override string HeaderName => "zx80";
/// <inheritdoc />
public override string WebName => "";
/// <inheritdoc />
public override int WindowsCodePage => 0;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => false;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The ZX80 to Unicode character map.</summary>
protected override Rune[] CharTable => new[]
{
const string _bodyname = "zx80";
const int _codepage = 0;
const string _encodingname = "Sinclair ZX80 character set";
const string _headername = "zx80";
const string _webname = "";
const int _windowsCodepage = 0;
const bool browserDisplay = false;
const bool browserSave = false;
const bool mailNewsDisplay = false;
const bool mailNewsSave = false;
const bool readOnly = false;
const bool singleByte = true;
/// <summary>
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
/// </summary>
public bool IsBrowserDisplay {
get { return browserDisplay; }
}
/// <summary>
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
/// </summary>
public bool IsBrowserSave {
get { return browserSave; }
}
/// <summary>
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
/// </summary>
public bool IsMailNewsDisplay {
get { return mailNewsDisplay; }
}
/// <summary>
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
/// </summary>
public bool IsMailNewsSave {
get { return mailNewsSave; }
}
/// <summary>
/// Gets a value indicating whether the current encoding is read-only.
/// </summary>
/// <value>The is single byte.</value>
public bool IsReadOnly {
get { return readOnly; }
}
/// <summary>
/// Gets a value indicating whether the current encoding uses single-byte code points.
/// </summary>
public bool IsSingleByte {
get { return singleByte; }
}
/// <summary>
/// Gets the code page identifier of the current Encoding.
/// </summary>
public int CodePage {
get { return _codepage; }
}
/// <summary>
/// Gets a name for the current encoding that can be used with mail agent body tags
/// </summary>
public string BodyName {
get { return _bodyname; }
}
/// <summary>
/// Gets a name for the current encoding that can be used with mail agent header tags
/// </summary>
public string HeaderName {
get { return _headername; }
}
/// <summary>
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
/// </summary>
public override string WebName {
get { return _webname; }
}
/// <summary>
/// Gets the human-readable description of the current encoding.
/// </summary>
public string EncodingName {
get { return _encodingname; }
}
/// <summary>
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
/// </summary>
public int WindowsCodePage {
get { return _windowsCodepage; }
}
/// <summary>
/// Calculates the number of bytes produced by encoding the characters in the specified <see cref="string"/>.
/// </summary>
/// <returns>The number of bytes produced by encoding the specified characters.</returns>
/// <param name="s">The <see cref="string"/> containing the set of characters to encode.</param>
public override int GetByteCount(string s)
{
if(s == null)
throw new ArgumentNullException(nameof(s));
return s.Length;
}
/// <summary>
/// Calculates the number of bytes produced by encoding a set of characters from the specified character array.
/// </summary>
/// <returns>The number of bytes produced by encoding the specified characters.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="index">The index of the first character to encode.</param>
/// <param name="count">The number of characters to encode.</param>
public override int GetByteCount(char[] chars, int index, int count)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(index < 0 || index >= chars.Length)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0 || index + count > chars.Length)
throw new ArgumentOutOfRangeException(nameof(index));
return count;
}
/// <summary>
/// Calculates the number of bytes produced by encoding all the characters in the specified character array.
/// </summary>
/// <returns>The number of bytes produced by encoding all the characters in the specified character array.</returns>
/// <param name="chars">The character array containing the characters to encode.</param>
public override int GetByteCount(char[] chars)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
/// <summary>
/// Encodes a set of characters from the specified <see cref="string"/> into the specified byte array.
/// </summary>
/// <returns>The actual number of bytes written into bytes.</returns>
/// <param name="s">The <see cref="string"/> containing the set of characters to encode.</param>
/// <param name="charIndex">The index of the first character to encode.</param>
/// <param name="charCount">The number of characters to encode.</param>
/// <param name="bytes">The byte array to contain the resulting sequence of bytes.</param>
/// <param name="byteIndex">The index at which to start writing the resulting sequence of bytes.</param>
public override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
{
return GetBytes(s.ToCharArray(), charIndex, charCount, bytes, byteIndex);
}
/// <summary>
/// Encodes all the characters in the specified string into a sequence of bytes.
/// </summary>
/// <returns>A byte array containing the results of encoding the specified set of characters.</returns>
/// <param name="s">The string containing the characters to encode.</param>
public override byte[] GetBytes(string s)
{
if(s == null)
throw new ArgumentNullException(nameof(s));
return GetBytes(s.ToCharArray(), 0, s.Length);
}
/// <summary>
/// Encodes a set of characters from the specified character array into the specified byte array.
/// </summary>
/// <returns>The actual number of bytes written into bytes.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="charIndex">The index of the first character to encode.</param>
/// <param name="charCount">The number of characters to encode.</param>
/// <param name="bytes">The byte array to contain the resulting sequence of bytes.</param>
/// <param name="byteIndex">The index at which to start writing the resulting sequence of bytes.</param>
public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(charIndex < 0)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if(charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount));
if(byteIndex < 0)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if(charIndex >= chars.Length)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if(charCount + charIndex > chars.Length)
throw new ArgumentOutOfRangeException(nameof(charCount));
if(byteIndex >= bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if(byteIndex + charCount > bytes.Length)
throw new ArgumentException(nameof(bytes));
byte[] temp = GetBytes(chars, charIndex, charCount);
for(int i = 0; i < temp.Length; i++)
bytes[i + byteIndex] = temp[i];
return charCount;
}
/// <summary>
/// Encodes a set of characters from the specified character array into a sequence of bytes.
/// </summary>
/// <returns>A byte array containing the results of encoding the specified set of characters.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="index">The index of the first character to encode.</param>
/// <param name="count">The number of characters to encode.</param>
public override byte[] GetBytes(char[] chars, int index, int count)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if(count + index > chars.Length)
throw new ArgumentOutOfRangeException(nameof(count));
byte[] bytes = new byte[count];
for(int i = 0; i < count; i++)
bytes[i] = GetByte(chars[index + i]);
return bytes;
}
/// <summary>
/// Encodes all the characters in the specified character array into a sequence of bytes.
/// </summary>
/// <returns>A byte array containing the results of encoding the specified set of characters.</returns>
/// <param name="chars">The character array containing the characters to encode.</param>
public override byte[] GetBytes(char[] chars)
{
return GetBytes(chars, 0, chars.Length);
}
/// <summary>
/// Calculates the number of characters produced by decoding all the bytes in the specified byte array.
/// </summary>
/// <returns>The number of characters produced by decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
public override int GetCharCount(byte[] bytes)
{
return GetCharCount(bytes, 0, bytes.Length);
}
/// <summary>
/// Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.
/// </summary>
/// <returns>The number of characters produced by decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override int GetCharCount(byte[] bytes, int index, int count)
{
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if(count + index > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(count));
return count;
}
/// <summary>
/// Decodes a sequence of bytes from the specified byte array into the specified character array.
/// </summary>
/// <returns>The actual number of characters written into chars.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="byteIndex">The index of the first byte to decode.</param>
/// <param name="byteCount">The number of bytes to decode.</param>
/// <param name="chars">The character array to contain the resulting set of characters.</param>
/// <param name="charIndex">The index at which to start writing the resulting set of characters.</param>
public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
{
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(byteIndex < 0)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if(byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount));
if(charIndex < 0)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if(byteIndex >= bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if(byteCount + byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteCount));
if(charIndex >= chars.Length)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if(charIndex + byteCount > chars.Length)
throw new ArgumentException(nameof(chars));
char[] temp = GetChars(bytes, byteIndex, byteCount);
for(int i = 0; i < temp.Length; i++)
chars[i + charIndex] = temp[i];
return byteCount;
}
/// <summary>
/// Decodes all the bytes in the specified byte array into a set of characters.
/// </summary>
/// <returns>A character array containing the results of decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
public override char[] GetChars(byte[] bytes)
{
return GetChars(bytes, 0, bytes.Length);
}
/// <summary>
/// Decodes a sequence of bytes from the specified byte array into a set of characters.
/// </summary>
/// <returns>The chars.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override char[] GetChars(byte[] bytes, int index, int count)
{
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if(count + index > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(count));
char[] chars = new char[count];
for(int i = 0; i < count; i++)
chars[i] = GetChar(bytes[index + i]);
return chars;
}
/// <summary>
/// Calculates the maximum number of bytes produced by encoding the specified number of characters.
/// </summary>
/// <returns>The maximum number of bytes produced by encoding the specified number of characters.</returns>
/// <param name="charCount">The number of characters to encode.</param>
public override int GetMaxByteCount(int charCount)
{
if(charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
/// <summary>
/// Calculates the maximum number of characters produced by decoding the specified number of bytes.
/// </summary>
/// <returns>The maximum number of characters produced by decoding the specified number of bytes.</returns>
/// <param name="byteCount">The number of bytes to decode.</param>
public override int GetMaxCharCount(int byteCount)
{
if(byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
/// <summary>
/// Returns a sequence of bytes that specifies the encoding used.
/// </summary>
/// <returns>A byte array of length zero, as a preamble is not required.</returns>
public override byte[] GetPreamble()
{
return new byte[0];
}
/// <summary>
/// Decodes all the bytes in the specified byte array into a string.
/// </summary>
/// <returns>A string that contains the results of decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
public string GetString(byte[] bytes)
{
return GetString(bytes, 0, bytes.Length);
}
/// <summary>
/// Decodes a sequence of bytes from the specified byte array into a string.
/// </summary>
/// <returns>A string that contains the results of decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override string GetString(byte[] bytes, int index, int count)
{
return new string(GetChars(bytes, index, count));
}
/// <summary>
/// The ZX80 to Unicode character map.
/// </summary>
static readonly char[] ZX80Table = {
// 0x00
'\u0020','\u0022','\u258C','\u2584','\u2598','\u259D','\u2596','\u2597',
// 0x08
'\u259E','\u2592','\uFFFD','\uFFFD','\u00A3','\u0024','\u003A','\u003F',
// 0x10
'\u0028','\u0029','\u002D','\u002B','\u002A','\u002F','\u003D','\u003E',
// 0x18
'\u003C','\u003B','\u002C','\u002E','\u0030','\u0031','\u0032','\u0033',
// 0x20
'\u0034','\u0035','\u0036','\u0037','\u0038','\u0039','\u0041','\u0042',
// 0x28
'\u0043','\u0044','\u0045','\u0046','\u0047','\u0048','\u0049','\u004A',
// 0x30
'\u004B','\u004C','\u004D','\u004E','\u004F','\u0050','\u0051','\u0052',
// 0x38
'\u0053','\u0054','\u0055','\u0056','\u0057','\u0058','\u0059','\u005A',
// 0x40
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0x48
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0x50
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0x58
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0x60
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0x68
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0x70
'\uFFFF','\uFFFF','\uFFFF','\uFFFF','\u000D','\uFFFD','\u000A','\u0008',
// 0x78
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0x80
'\u2588','\uFFFD','\u2590','\u2580','\u2599','\u259C','\u259B','\u259A',
// 0x88
'\u2592','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD',
// 0x90
'\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD',
// 0x98
'\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD',
// 0xA0
'\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD',
// 0xA8
'\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD',
// 0xB0
'\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD',
// 0xB8
'\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD',
// 0xC0
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0xC8
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0xD0
'\u0000','\u0000','\u0000','\u0000','\uFFFF','\uFFFF','\uFFFF','\uFFFF',
// 0xD8
'\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF',
// 0xE0
'\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF',
// 0xE8
'\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF',
// 0xF0
'\uFFFF','\u0000','\u0000','\uFFFF','\uFFFF','\u0000','\uFFFF','\uFFFF',
// 0xF8
'\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\u0000'
};
/// <summary>
/// Converts a ZX80 character to an Unicode character
/// </summary>
/// <returns>Unicode character.</returns>
/// <param name="character">ZX80 character.</param>
static char GetChar(byte character)
{
return ZX80Table[character];
}
/// <summary>
/// Converts a Unicode character to an ZX80 character
/// </summary>
/// <returns>ZX80 character.</returns>
/// <param name="character">Unicode character.</param>
static byte GetByte(char character)
{
switch(character) {
case '\u0020':
return 0x00;
case '\u0022':
return 0x01;
case '\u258C':
return 0x02;
case '\u2584':
return 0x03;
case '\u2598':
return 0x04;
case '\u259D':
return 0x05;
case '\u2596':
return 0x06;
case '\u2597':
return 0x07;
case '\u259E':
return 0x08;
case '\u2592':
return 0x09;
case '\u00A3':
return 0x0C;
case '\u0024':
return 0x0D;
case '\u003A':
return 0x0E;
case '\u003F':
return 0x0F;
case '\u0028':
return 0x10;
case '\u0029':
return 0x11;
case '\u002D':
return 0x12;
case '\u002B':
return 0x13;
case '\u002A':
return 0x14;
case '\u002F':
return 0x15;
case '\u003D':
return 0x16;
case '\u003E':
return 0x17;
case '\u003C':
return 0x18;
case '\u003B':
return 0x19;
case '\u002C':
return 0x1A;
case '\u002E':
return 0x1B;
case '\u0030':
return 0x1C;
case '\u0031':
return 0x1D;
case '\u0032':
return 0x1E;
case '\u0033':
return 0x1F;
case '\u0034':
return 0x20;
case '\u0035':
return 0x21;
case '\u0036':
return 0x22;
case '\u0037':
return 0x23;
case '\u0038':
return 0x24;
case '\u0039':
return 0x25;
case '\u0041':
return 0x26;
case '\u0042':
return 0x27;
case '\u0043':
return 0x28;
case '\u0044':
return 0x29;
case '\u0045':
return 0x2A;
case '\u0046':
return 0x2B;
case '\u0047':
return 0x2C;
case '\u0048':
return 0x2D;
case '\u0049':
return 0x2E;
case '\u004A':
return 0x2F;
case '\u004B':
return 0x30;
case '\u004C':
return 0x31;
case '\u004D':
return 0x32;
case '\u004E':
return 0x33;
case '\u004F':
return 0x34;
case '\u0050':
return 0x35;
case '\u0051':
return 0x36;
case '\u0052':
return 0x37;
case '\u0053':
return 0x38;
case '\u0054':
return 0x39;
case '\u0055':
return 0x3A;
case '\u0056':
return 0x3B;
case '\u0057':
return 0x3C;
case '\u0058':
return 0x3D;
case '\u0059':
return 0x3E;
case '\u005A':
return 0x3F;
case '\u000D':
return 0x74;
case '\u000A':
return 0x76;
case '\u0008':
return 0x77;
case '\u2588':
return 0x80;
case '\u2590':
return 0x82;
case '\u2580':
return 0x83;
case '\u259F':
return 0x84;
case '\u2599':
return 0x85;
case '\u259C':
return 0x86;
case '\u259B':
return 0x87;
case '\u259A':
return 0x88;
default:
// Fallback to '?'
return 0x0F;
}
}
}
// 0x00
new Rune(0x0020), new Rune(0x0022), new Rune(0x258C), new Rune(0x2584), new Rune(0x2598), new Rune(0x259D),
new Rune(0x2596), new Rune(0x2597),
// 0x08
new Rune(0x259E), new Rune(0x2592), new Rune(0x1FB8F), new Rune(0x1FB8E), new Rune(0x00A3), new Rune(0x0024),
new Rune(0x003A), new Rune(0x003F),
// 0x10
new Rune(0x0028), new Rune(0x0029), new Rune(0x002D), new Rune(0x002B), new Rune(0x002A), new Rune(0x002F),
new Rune(0x003D), new Rune(0x003E),
// 0x18
new Rune(0x003C), new Rune(0x003B), new Rune(0x002C), new Rune(0x002E), new Rune(0x0030), new Rune(0x0031),
new Rune(0x0032), new Rune(0x0033),
// 0x20
new Rune(0x0034), new Rune(0x0035), new Rune(0x0036), new Rune(0x0037), new Rune(0x0038), new Rune(0x0039),
new Rune(0x0041), new Rune(0x0042),
// 0x28
new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), new Rune(0x0046), new Rune(0x0047), new Rune(0x0048),
new Rune(0x0049), new Rune(0x004A),
// 0x30
new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), new Rune(0x004E), new Rune(0x004F), new Rune(0x0050),
new Rune(0x0051), new Rune(0x0052),
// 0x38
new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), new Rune(0x0056), new Rune(0x0057), new Rune(0x0058),
new Rune(0x0059), new Rune(0x005A),
// 0x40
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x48
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x50
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x58
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x60
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x68
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x70
new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0x000D), new Rune(0xFFFD),
new Rune(0x000A), new Rune(0x0008),
// 0x78
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x80
new Rune(0x2588), new Rune(0xFFFD), new Rune(0x2590), new Rune(0x2580), new Rune(0x2599), new Rune(0x259C),
new Rune(0x259B), new Rune(0x259A),
// 0x88
new Rune(0x2592), new Rune(0x1FB90), new Rune(0x1FB91), new Rune(0x1FB92), new Rune(0xFFFD), new Rune(0xFFFD),
new Rune(0xFFFD), new Rune(0xFFFD),
// 0x90
new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD),
new Rune(0xFFFD), new Rune(0xFFFD),
// 0x98
new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD),
new Rune(0xFFFD), new Rune(0xFFFD),
// 0xA0
new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD),
new Rune(0xFFFD), new Rune(0xFFFD),
// 0xA8
new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD),
new Rune(0xFFFD), new Rune(0xFFFD),
// 0xB0
new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD),
new Rune(0xFFFD), new Rune(0xFFFD),
// 0xB8
new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD),
new Rune(0xFFFD), new Rune(0xFFFD),
// 0xC0
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0xC8
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0xD0
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0xFFFF), new Rune(0xFFFF),
new Rune(0xFFFF), new Rune(0xFFFF),
// 0xD8
new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF),
new Rune(0xFFFF), new Rune(0xFFFF),
// 0xE0
new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF),
new Rune(0xFFFF), new Rune(0xFFFF),
// 0xE8
new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF),
new Rune(0xFFFF), new Rune(0xFFFF),
// 0xF0
new Rune(0xFFFF), new Rune(0x0000), new Rune(0x0000), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0x0000),
new Rune(0xFFFF), new Rune(0xFFFF),
// 0xF8
new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF),
new Rune(0xFFFF), new Rune(0x0000)
};
/// <summary>Converts a Unicode character to an ZX80 character</summary>
/// <returns>ZX80 character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(Rune character) => character.Value switch
{
0x0020 => 0x00,
0x0022 => 0x01,
0x258C => 0x02,
0x2584 => 0x03,
0x2598 => 0x04,
0x259D => 0x05,
0x2596 => 0x06,
0x2597 => 0x07,
0x259E => 0x08,
0x2592 => 0x09,
0x1FB8F => 0x0A,
0x1FB8E => 0x0B,
0x00A3 => 0x0C,
0x0024 => 0x0D,
0x003A => 0x0E,
0x003F => 0x0F,
0x0028 => 0x10,
0x0029 => 0x11,
0x002D => 0x12,
0x002B => 0x13,
0x002A => 0x14,
0x002F => 0x15,
0x003D => 0x16,
0x003E => 0x17,
0x003C => 0x18,
0x003B => 0x19,
0x002C => 0x1A,
0x002E => 0x1B,
0x0030 => 0x1C,
0x0031 => 0x1D,
0x0032 => 0x1E,
0x0033 => 0x1F,
0x0034 => 0x20,
0x0035 => 0x21,
0x0036 => 0x22,
0x0037 => 0x23,
0x0038 => 0x24,
0x0039 => 0x25,
0x0041 => 0x26,
0x0042 => 0x27,
0x0043 => 0x28,
0x0044 => 0x29,
0x0045 => 0x2A,
0x0046 => 0x2B,
0x0047 => 0x2C,
0x0048 => 0x2D,
0x0049 => 0x2E,
0x004A => 0x2F,
0x004B => 0x30,
0x004C => 0x31,
0x004D => 0x32,
0x004E => 0x33,
0x004F => 0x34,
0x0050 => 0x35,
0x0051 => 0x36,
0x0052 => 0x37,
0x0053 => 0x38,
0x0054 => 0x39,
0x0055 => 0x3A,
0x0056 => 0x3B,
0x0057 => 0x3C,
0x0058 => 0x3D,
0x0059 => 0x3E,
0x005A => 0x3F,
0x000D => 0x74,
0x000A => 0x76,
0x0008 => 0x77,
0x2588 => 0x80,
0x2590 => 0x82,
0x2580 => 0x83,
0x259F => 0x84,
0x2599 => 0x85,
0x259C => 0x86,
0x259B => 0x87,
0x259A => 0x88,
0x1FB90 => 0x89,
0x1FB91 => 0x8A,
0x1FB92 => 0x8B,
_ => 0x0F
};
}

View File

@@ -4,7 +4,7 @@
// Author:
// Natalia Portillo <claunia@claunia.com>
//
// Copyright (c) 2016 © Claunia.com
// Copyright © 2016-2021 Natalia Portillo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -24,687 +24,252 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace Claunia.Encoding;
namespace Claunia.Encoding
/// <summary>Represents a ZX81 character encoding of Unicode characters.</summary>
public class ZX81 : SingleByteEncodingWithRunes
{
/// <summary>
/// Represents a ZX81 character encoding of Unicode characters.
/// </summary>
public class ZX81 : System.Text.Encoding
/// <inheritdoc />
public override string BodyName => "zx81";
/// <inheritdoc />
public override int CodePage => 0;
/// <inheritdoc />
public override string EncodingName => "Sinclair ZX81 character set";
/// <inheritdoc />
public override string HeaderName => "zx81";
/// <inheritdoc />
public override string WebName => "";
/// <inheritdoc />
public override int WindowsCodePage => 0;
/// <inheritdoc />
public override bool IsBrowserDisplay => false;
/// <inheritdoc />
public override bool IsBrowserSave => false;
/// <inheritdoc />
public override bool IsMailNewsDisplay => false;
/// <inheritdoc />
public override bool IsMailNewsSave => false;
/// <inheritdoc />
public override bool IsReadOnly => false;
/// <inheritdoc />
public override bool IsSingleByte => true;
/// <summary>The ZX81 to Unicode character map.</summary>
protected override Rune[] CharTable => new[]
{
const string _bodyname = "zx81";
const int _codepage = 0;
const string _encodingname = "Sinclair ZX81 character set";
const string _headername = "zx81";
const string _webname = "";
const int _windowsCodepage = 0;
const bool browserDisplay = false;
const bool browserSave = false;
const bool mailNewsDisplay = false;
const bool mailNewsSave = false;
const bool readOnly = false;
const bool singleByte = true;
/// <summary>
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
/// </summary>
public bool IsBrowserDisplay {
get { return browserDisplay; }
}
/// <summary>
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
/// </summary>
public bool IsBrowserSave {
get { return browserSave; }
}
/// <summary>
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
/// </summary>
public bool IsMailNewsDisplay {
get { return mailNewsDisplay; }
}
/// <summary>
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
/// </summary>
public bool IsMailNewsSave {
get { return mailNewsSave; }
}
/// <summary>
/// Gets a value indicating whether the current encoding is read-only.
/// </summary>
/// <value>The is single byte.</value>
public bool IsReadOnly {
get { return readOnly; }
}
/// <summary>
/// Gets a value indicating whether the current encoding uses single-byte code points.
/// </summary>
public bool IsSingleByte {
get { return singleByte; }
}
/// <summary>
/// Gets the code page identifier of the current Encoding.
/// </summary>
public int CodePage {
get { return _codepage; }
}
/// <summary>
/// Gets a name for the current encoding that can be used with mail agent body tags
/// </summary>
public string BodyName {
get { return _bodyname; }
}
/// <summary>
/// Gets a name for the current encoding that can be used with mail agent header tags
/// </summary>
public string HeaderName {
get { return _headername; }
}
/// <summary>
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
/// </summary>
public override string WebName {
get { return _webname; }
}
/// <summary>
/// Gets the human-readable description of the current encoding.
/// </summary>
public string EncodingName {
get { return _encodingname; }
}
/// <summary>
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
/// </summary>
public int WindowsCodePage {
get { return _windowsCodepage; }
}
/// <summary>
/// Calculates the number of bytes produced by encoding the characters in the specified <see cref="string"/>.
/// </summary>
/// <returns>The number of bytes produced by encoding the specified characters.</returns>
/// <param name="s">The <see cref="string"/> containing the set of characters to encode.</param>
public override int GetByteCount(string s)
{
if(s == null)
throw new ArgumentNullException(nameof(s));
return s.Length;
}
/// <summary>
/// Calculates the number of bytes produced by encoding a set of characters from the specified character array.
/// </summary>
/// <returns>The number of bytes produced by encoding the specified characters.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="index">The index of the first character to encode.</param>
/// <param name="count">The number of characters to encode.</param>
public override int GetByteCount(char[] chars, int index, int count)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(index < 0 || index >= chars.Length)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0 || index + count > chars.Length)
throw new ArgumentOutOfRangeException(nameof(index));
return count;
}
/// <summary>
/// Calculates the number of bytes produced by encoding all the characters in the specified character array.
/// </summary>
/// <returns>The number of bytes produced by encoding all the characters in the specified character array.</returns>
/// <param name="chars">The character array containing the characters to encode.</param>
public override int GetByteCount(char[] chars)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
/// <summary>
/// Encodes a set of characters from the specified <see cref="string"/> into the specified byte array.
/// </summary>
/// <returns>The actual number of bytes written into bytes.</returns>
/// <param name="s">The <see cref="string"/> containing the set of characters to encode.</param>
/// <param name="charIndex">The index of the first character to encode.</param>
/// <param name="charCount">The number of characters to encode.</param>
/// <param name="bytes">The byte array to contain the resulting sequence of bytes.</param>
/// <param name="byteIndex">The index at which to start writing the resulting sequence of bytes.</param>
public override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
{
return GetBytes(s.ToCharArray(), charIndex, charCount, bytes, byteIndex);
}
/// <summary>
/// Encodes all the characters in the specified string into a sequence of bytes.
/// </summary>
/// <returns>A byte array containing the results of encoding the specified set of characters.</returns>
/// <param name="s">The string containing the characters to encode.</param>
public override byte[] GetBytes(string s)
{
if(s == null)
throw new ArgumentNullException(nameof(s));
return GetBytes(s.ToCharArray(), 0, s.Length);
}
/// <summary>
/// Encodes a set of characters from the specified character array into the specified byte array.
/// </summary>
/// <returns>The actual number of bytes written into bytes.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="charIndex">The index of the first character to encode.</param>
/// <param name="charCount">The number of characters to encode.</param>
/// <param name="bytes">The byte array to contain the resulting sequence of bytes.</param>
/// <param name="byteIndex">The index at which to start writing the resulting sequence of bytes.</param>
public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(charIndex < 0)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if(charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount));
if(byteIndex < 0)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if(charIndex >= chars.Length)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if(charCount + charIndex > chars.Length)
throw new ArgumentOutOfRangeException(nameof(charCount));
if(byteIndex >= bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if(byteIndex + charCount > bytes.Length)
throw new ArgumentException(nameof(bytes));
byte[] temp = GetBytes(chars, charIndex, charCount);
for(int i = 0; i < temp.Length; i++)
bytes[i + byteIndex] = temp[i];
return charCount;
}
/// <summary>
/// Encodes a set of characters from the specified character array into a sequence of bytes.
/// </summary>
/// <returns>A byte array containing the results of encoding the specified set of characters.</returns>
/// <param name="chars">The character array containing the set of characters to encode.</param>
/// <param name="index">The index of the first character to encode.</param>
/// <param name="count">The number of characters to encode.</param>
public override byte[] GetBytes(char[] chars, int index, int count)
{
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if(count + index > chars.Length)
throw new ArgumentOutOfRangeException(nameof(count));
byte[] bytes = new byte[count];
for(int i = 0; i < count; i++)
bytes[i] = GetByte(chars[index + i]);
return bytes;
}
/// <summary>
/// Encodes all the characters in the specified character array into a sequence of bytes.
/// </summary>
/// <returns>A byte array containing the results of encoding the specified set of characters.</returns>
/// <param name="chars">The character array containing the characters to encode.</param>
public override byte[] GetBytes(char[] chars)
{
return GetBytes(chars, 0, chars.Length);
}
/// <summary>
/// Calculates the number of characters produced by decoding all the bytes in the specified byte array.
/// </summary>
/// <returns>The number of characters produced by decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
public override int GetCharCount(byte[] bytes)
{
return GetCharCount(bytes, 0, bytes.Length);
}
/// <summary>
/// Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array.
/// </summary>
/// <returns>The number of characters produced by decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override int GetCharCount(byte[] bytes, int index, int count)
{
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if(count + index > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(count));
return count;
}
/// <summary>
/// Decodes a sequence of bytes from the specified byte array into the specified character array.
/// </summary>
/// <returns>The actual number of characters written into chars.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="byteIndex">The index of the first byte to decode.</param>
/// <param name="byteCount">The number of bytes to decode.</param>
/// <param name="chars">The character array to contain the resulting set of characters.</param>
/// <param name="charIndex">The index at which to start writing the resulting set of characters.</param>
public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
{
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(chars == null)
throw new ArgumentNullException(nameof(chars));
if(byteIndex < 0)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if(byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount));
if(charIndex < 0)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if(byteIndex >= bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteIndex));
if(byteCount + byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteCount));
if(charIndex >= chars.Length)
throw new ArgumentOutOfRangeException(nameof(charIndex));
if(charIndex + byteCount > chars.Length)
throw new ArgumentException(nameof(chars));
char[] temp = GetChars(bytes, byteIndex, byteCount);
for(int i = 0; i < temp.Length; i++)
chars[i + charIndex] = temp[i];
return byteCount;
}
/// <summary>
/// Decodes all the bytes in the specified byte array into a set of characters.
/// </summary>
/// <returns>A character array containing the results of decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
public override char[] GetChars(byte[] bytes)
{
return GetChars(bytes, 0, bytes.Length);
}
/// <summary>
/// Decodes a sequence of bytes from the specified byte array into a set of characters.
/// </summary>
/// <returns>The chars.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override char[] GetChars(byte[] bytes, int index, int count)
{
if(bytes == null)
throw new ArgumentNullException(nameof(bytes));
if(index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
if(count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if(count + index > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(count));
char[] chars = new char[count];
for(int i = 0; i < count; i++)
chars[i] = GetChar(bytes[index + i]);
return chars;
}
/// <summary>
/// Calculates the maximum number of bytes produced by encoding the specified number of characters.
/// </summary>
/// <returns>The maximum number of bytes produced by encoding the specified number of characters.</returns>
/// <param name="charCount">The number of characters to encode.</param>
public override int GetMaxByteCount(int charCount)
{
if(charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
/// <summary>
/// Calculates the maximum number of characters produced by decoding the specified number of bytes.
/// </summary>
/// <returns>The maximum number of characters produced by decoding the specified number of bytes.</returns>
/// <param name="byteCount">The number of bytes to decode.</param>
public override int GetMaxCharCount(int byteCount)
{
if(byteCount < 0)
throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
/// <summary>
/// Returns a sequence of bytes that specifies the encoding used.
/// </summary>
/// <returns>A byte array of length zero, as a preamble is not required.</returns>
public override byte[] GetPreamble()
{
return new byte[0];
}
/// <summary>
/// Decodes all the bytes in the specified byte array into a string.
/// </summary>
/// <returns>A string that contains the results of decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
public string GetString(byte[] bytes)
{
return GetString(bytes, 0, bytes.Length);
}
/// <summary>
/// Decodes a sequence of bytes from the specified byte array into a string.
/// </summary>
/// <returns>A string that contains the results of decoding the specified sequence of bytes.</returns>
/// <param name="bytes">The byte array containing the sequence of bytes to decode.</param>
/// <param name="index">The index of the first byte to decode.</param>
/// <param name="count">The number of bytes to decode.</param>
public override string GetString(byte[] bytes, int index, int count)
{
return new string(GetChars(bytes, index, count));
}
/// <summary>
/// The ZX81 to Unicode character map.
/// </summary>
static readonly char[] ZX81Table = {
// 0x00
'\u0020','\u2598','\u259D','\u2580','\u2596','\u258C','\u259E','\u259B',
// 0x08
'\u2592','\uFFFD','\uFFFD','\u0022','\u00A3','\u0024','\u003A','\u003F',
// 0x10
'\u0028','\u0029','\u003E','\u003C','\u003D','\u002B','\u002D','\u002A',
// 0x18
'\u002F','\u003B','\u002C','\u002E','\u0030','\u0031','\u0032','\u0033',
// 0x20
'\u0034','\u0035','\u0036','\u0037','\u0038','\u0039','\u0041','\u0042',
// 0x28
'\u0043','\u0044','\u0045','\u0046','\u0047','\u0048','\u0049','\u004A',
// 0x30
'\u004B','\u004C','\u004D','\u004E','\u004F','\u0050','\u0051','\u0052',
// 0x38
'\u0053','\u0054','\u0055','\u0056','\u0057','\u0058','\u0059','\u005A',
// 0x40
'\uFFFF','\uFFFF','\uFFFF','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0x48
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0x50
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0x58
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0x60
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0x68
'\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000','\u0000',
// 0x70
'\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\u000A','\u0008',
// 0x78
'\uFFFF','\uFFFF','\u0000','\u0000','\u0000','\u0000','\uFFFF','\uFFFF',
// 0x80
'\u2588','\u259F','\u2599','\u2584','\u259C','\u2590','\u259A','\u2597',
// 0x88
'\u2592','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD',
// 0x90
'\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD',
// 0x98
'\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD',
// 0xA0
'\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD',
// 0xA8
'\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD',
// 0xB0
'\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD',
// 0xB8
'\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD','\uFFFD',
// 0xC0
'\uFFFF','\uFFFF','\uFFFF','\u0000','\uFFFF','\uFFFF','\uFFFF','\uFFFF',
// 0xC8
'\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF',
// 0xD0
'\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF',
// 0xD8
'\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF',
// 0xE0
'\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF',
// 0xE8
'\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF',
// 0xF0
'\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF',
// 0xF8
'\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF','\uFFFF'
};
/// <summary>
/// Converts a ZX81 character to an Unicode character
/// </summary>
/// <returns>Unicode character.</returns>
/// <param name="character">ZX81 character.</param>
static char GetChar(byte character)
{
return ZX81Table[character];
}
/// <summary>
/// Converts a Unicode character to an ZX81 character
/// </summary>
/// <returns>ZX81 character.</returns>
/// <param name="character">Unicode character.</param>
static byte GetByte(char character)
{
switch(character) {
case '\u0020':
return 0x00;
case '\u2598':
return 0x01;
case '\u259D':
return 0x02;
case '\u2580':
return 0x03;
case '\u2596':
return 0x04;
case '\u258C':
return 0x05;
case '\u259E':
return 0x06;
case '\u259B':
return 0x07;
case '\u2592':
return 0x08;
case '\u0022':
return 0x0B;
case '\u00A3':
return 0x0C;
case '\u0024':
return 0x0D;
case '\u003A':
return 0x0E;
case '\u003F':
return 0x0F;
case '\u0028':
return 0x10;
case '\u0029':
return 0x11;
case '\u003E':
return 0x12;
case '\u003C':
return 0x13;
case '\u003D':
return 0x14;
case '\u002B':
return 0x15;
case '\u002D':
return 0x16;
case '\u002A':
return 0x17;
case '\u002F':
return 0x18;
case '\u003B':
return 0x19;
case '\u002C':
return 0x1A;
case '\u002E':
return 0x1B;
case '\u0030':
return 0x1C;
case '\u0031':
return 0x1D;
case '\u0032':
return 0x1E;
case '\u0033':
return 0x1F;
case '\u0034':
return 0x20;
case '\u0035':
return 0x21;
case '\u0036':
return 0x22;
case '\u0037':
return 0x23;
case '\u0038':
return 0x24;
case '\u0039':
return 0x25;
case '\u0041':
return 0x26;
case '\u0042':
return 0x27;
case '\u0043':
return 0x28;
case '\u0044':
return 0x29;
case '\u0045':
return 0x2A;
case '\u0046':
return 0x2B;
case '\u0047':
return 0x2C;
case '\u0048':
return 0x2D;
case '\u0049':
return 0x2E;
case '\u004A':
return 0x2F;
case '\u004B':
return 0x30;
case '\u004C':
return 0x31;
case '\u004D':
return 0x32;
case '\u004E':
return 0x33;
case '\u004F':
return 0x34;
case '\u0050':
return 0x35;
case '\u0051':
return 0x36;
case '\u0052':
return 0x37;
case '\u0053':
return 0x38;
case '\u0054':
return 0x39;
case '\u0055':
return 0x3A;
case '\u0056':
return 0x3B;
case '\u0057':
return 0x3C;
case '\u0058':
return 0x3D;
case '\u0059':
return 0x3E;
case '\u005A':
return 0x3F;
case '\u000D':
return 0x74;
case '\u000A':
return 0x76;
case '\u0008':
return 0x77;
case '\u2588':
return 0x80;
case '\u259F':
return 0x81;
case '\u2599':
return 0x82;
case '\u2584':
return 0x83;
case '\u259C':
return 0x84;
case '\u2590':
return 0x85;
case '\u259A':
return 0x86;
case '\u2597':
return 0x87;
default:
// Fallback to '?'
return 0x0F;
}
}
}
// 0x00
new Rune(0x0020), new Rune(0x2598), new Rune(0x259D), new Rune(0x2580), new Rune(0x2596), new Rune(0x258C),
new Rune(0x259E), new Rune(0x259B),
// 0x08
new Rune(0x2592), new Rune(0x1FB8F), new Rune(0x1FB8E), new Rune(0x0022), new Rune(0x00A3), new Rune(0x0024),
new Rune(0x003A), new Rune(0x003F),
// 0x10
new Rune(0x0028), new Rune(0x0029), new Rune(0x003E), new Rune(0x003C), new Rune(0x003D), new Rune(0x002B),
new Rune(0x002D), new Rune(0x002A),
// 0x18
new Rune(0x002F), new Rune(0x003B), new Rune(0x002C), new Rune(0x002E), new Rune(0x0030), new Rune(0x0031),
new Rune(0x0032), new Rune(0x0033),
// 0x20
new Rune(0x0034), new Rune(0x0035), new Rune(0x0036), new Rune(0x0037), new Rune(0x0038), new Rune(0x0039),
new Rune(0x0041), new Rune(0x0042),
// 0x28
new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), new Rune(0x0046), new Rune(0x0047), new Rune(0x0048),
new Rune(0x0049), new Rune(0x004A),
// 0x30
new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), new Rune(0x004E), new Rune(0x004F), new Rune(0x0050),
new Rune(0x0051), new Rune(0x0052),
// 0x38
new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), new Rune(0x0056), new Rune(0x0057), new Rune(0x0058),
new Rune(0x0059), new Rune(0x005A),
// 0x40
new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x48
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x50
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x58
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x60
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x68
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0x0000), new Rune(0x0000),
// 0x70
new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF),
new Rune(0x000A), new Rune(0x0008),
// 0x78
new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
new Rune(0xFFFF), new Rune(0xFFFF),
// 0x80
new Rune(0x2588), new Rune(0x259F), new Rune(0x2599), new Rune(0x2584), new Rune(0x259C), new Rune(0x2590),
new Rune(0x259A), new Rune(0x2597),
// 0x88
new Rune(0x1FB90), new Rune(0x1FB91), new Rune(0x1FB92), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD),
new Rune(0xFFFD), new Rune(0xFFFD),
// 0x90
new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD),
new Rune(0xFFFD), new Rune(0xFFFD),
// 0x98
new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD),
new Rune(0xFFFD), new Rune(0xFFFD),
// 0xA0
new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD),
new Rune(0xFFFD), new Rune(0xFFFD),
// 0xA8
new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD),
new Rune(0xFFFD), new Rune(0xFFFD),
// 0xB0
new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD),
new Rune(0xFFFD), new Rune(0xFFFD),
// 0xB8
new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD),
new Rune(0xFFFD), new Rune(0xFFFD),
// 0xC0
new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0x0000), new Rune(0xFFFF), new Rune(0xFFFF),
new Rune(0xFFFF), new Rune(0xFFFF),
// 0xC8
new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF),
new Rune(0xFFFF), new Rune(0xFFFF),
// 0xD0
new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF),
new Rune(0xFFFF), new Rune(0xFFFF),
// 0xD8
new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF),
new Rune(0xFFFF), new Rune(0xFFFF),
// 0xE0
new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF),
new Rune(0xFFFF), new Rune(0xFFFF),
// 0xE8
new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF),
new Rune(0xFFFF), new Rune(0xFFFF),
// 0xF0
new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF),
new Rune(0xFFFF), new Rune(0xFFFF),
// 0xF8
new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF),
new Rune(0xFFFF), new Rune(0xFFFF)
};
/// <summary>Converts a Unicode character to an ZX81 character</summary>
/// <returns>ZX81 character.</returns>
/// <param name="character">Unicode character.</param>
private protected override byte GetByte(Rune character) => character.Value switch
{
0x0020 => 0x00,
0x2598 => 0x01,
0x259D => 0x02,
0x2580 => 0x03,
0x2596 => 0x04,
0x258C => 0x05,
0x259E => 0x06,
0x259B => 0x07,
0x2592 => 0x08,
0x1FB8F => 0x09,
0x1FB8E => 0x0A,
0x0022 => 0x0B,
0x00A3 => 0x0C,
0x0024 => 0x0D,
0x003A => 0x0E,
0x003F => 0x0F,
0x0028 => 0x10,
0x0029 => 0x11,
0x003E => 0x12,
0x003C => 0x13,
0x003D => 0x14,
0x002B => 0x15,
0x002D => 0x16,
0x002A => 0x17,
0x002F => 0x18,
0x003B => 0x19,
0x002C => 0x1A,
0x002E => 0x1B,
0x0030 => 0x1C,
0x0031 => 0x1D,
0x0032 => 0x1E,
0x0033 => 0x1F,
0x0034 => 0x20,
0x0035 => 0x21,
0x0036 => 0x22,
0x0037 => 0x23,
0x0038 => 0x24,
0x0039 => 0x25,
0x0041 => 0x26,
0x0042 => 0x27,
0x0043 => 0x28,
0x0044 => 0x29,
0x0045 => 0x2A,
0x0046 => 0x2B,
0x0047 => 0x2C,
0x0048 => 0x2D,
0x0049 => 0x2E,
0x004A => 0x2F,
0x004B => 0x30,
0x004C => 0x31,
0x004D => 0x32,
0x004E => 0x33,
0x004F => 0x34,
0x0050 => 0x35,
0x0051 => 0x36,
0x0052 => 0x37,
0x0053 => 0x38,
0x0054 => 0x39,
0x0055 => 0x3A,
0x0056 => 0x3B,
0x0057 => 0x3C,
0x0058 => 0x3D,
0x0059 => 0x3E,
0x005A => 0x3F,
0x000D => 0x74,
0x000A => 0x76,
0x0008 => 0x77,
0x2588 => 0x80,
0x259F => 0x81,
0x2599 => 0x82,
0x2584 => 0x83,
0x259C => 0x84,
0x2590 => 0x85,
0x259A => 0x86,
0x2597 => 0x87,
0x1FB90 => 0x88,
0x1FB91 => 0x89,
0x1FB92 => 0x8A,
_ => 0x0F
};
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NuGet.Build.Packaging" version="0.1.248" targetFramework="portable45-net45+win8+wp8" developmentDependency="true" />
<package id="NuGet.Build.Packaging" version="0.2.2" targetFramework="portable40-net40+sl5+win8+wp8"
developmentDependency="true"/>
</packages>

View File

@@ -3,14 +3,30 @@
Library to provide codepage conversion to and from archaic and old computer systems and Unicode.
Copyright © 2016 Natalia Portillo <claunia@claunia.com>
Copyright © 2016-2021 Natalia Portillo <claunia@claunia.com>
Supported encodings
==============================
* Apple II, IIc, IIe and IIgs
* Apple Lisa
* Atari Standard Code for Information Interchange (ATASCII)
* Atari ST character set
* Commodore PET Standard Code for Information Interchange (PETSCII)
* DEC Radix-50
* GEM Character Set
* GEOS Character Set
* MacArabic
* MacCentralEuropean
* MacCroatian
* MacCyrillic
* MacFarsi
* MacGreek
* MacHebrew
* MacRoman
* MacRomanian
* MacTurkish
* MacUkrainian
* Sinclair ZX80 character set
* Sinclair ZX81 character set
* Sinclair ZX Spectrum character set