mirror of
https://github.com/claunia/Claunia.Encoding.git
synced 2026-07-09 10:26:26 +00:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
240f586614
|
|||
|
ffa321c760
|
|||
|
8ff97425f9
|
|||
|
ffba6dbf05
|
|||
|
7e430d1a57
|
|||
|
27cb171968
|
|||
|
3b05c4f61f
|
|||
|
c63f2cf81e
|
|||
|
b91633a631
|
|||
|
2da99e07d6
|
|||
|
38eee129d1
|
|||
|
1ea66e73c6
|
|||
|
c3304d356d
|
|||
|
01df1f48e1
|
|||
|
852dd674a3
|
|||
|
99767331e0
|
|||
|
edfa3efaa3
|
|||
|
187aca10d9
|
|||
|
7cc7c1fce7
|
|||
|
3a2e7005e2
|
|||
|
64c98fd2f3
|
632
.editorconfig
Normal file
632
.editorconfig
Normal file
@@ -0,0 +1,632 @@
|
||||
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
|
||||
|
||||
[*.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
508
.gitignore
vendored
@@ -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
|
||||
|
||||
|
||||
16
.idea/.idea.Claunia.Encoding/.idea/csv-plugin.xml
generated
Normal file
16
.idea/.idea.Claunia.Encoding/.idea/csv-plugin.xml
generated
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CsvFileAttributes">
|
||||
<option name="attributeMap">
|
||||
<map>
|
||||
<entry key="/Claunia.Encoding/Gem.cs">
|
||||
<value>
|
||||
<Attribute>
|
||||
<option name="separator" value="," />
|
||||
</Attribute>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/.idea.Claunia.Encoding/.idea/indexLayout.xml
generated
Normal file
8
.idea/.idea.Claunia.Encoding/.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/.idea.Claunia.Encoding/.idea/projectSettingsUpdater.xml
generated
Normal file
6
.idea/.idea.Claunia.Encoding/.idea/projectSettingsUpdater.xml
generated
Normal 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>
|
||||
6
.idea/.idea.Claunia.Encoding/.idea/vcs.xml
generated
Normal file
6
.idea/.idea.Claunia.Encoding/.idea/vcs.xml
generated
Normal 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>
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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
|
||||
@@ -29,39 +29,48 @@ using NUnit.Framework;
|
||||
namespace Claunia.Encoding.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ATASCII
|
||||
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
|
||||
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 =
|
||||
const string DIGITS = "0123456789";
|
||||
readonly byte[] _digitsBytes =
|
||||
{
|
||||
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
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39
|
||||
};
|
||||
const string LowerLatin = "abcdefghijklmnopqrstuvwxyz";
|
||||
readonly byte[] LowerLatinBytes =
|
||||
const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
readonly byte[] _upperLatinBytes =
|
||||
{
|
||||
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
|
||||
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 =
|
||||
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
|
||||
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 Arrows = "↑↓←→↰◀▶";
|
||||
readonly byte[] ArrowsBytes = {0x1C, 0x1D, 0x1E, 0x1F, 0x7D, 0x7E, 0x7F};
|
||||
const string Decks = "♥♣♦♠";
|
||||
readonly byte[] DecksBytes = {0x00, 0x10, 0x60, 0x7B};
|
||||
|
||||
[Test]
|
||||
public void AtariPangrams()
|
||||
@@ -69,9 +78,9 @@ namespace Claunia.Encoding.Tests
|
||||
byte[] byteArray;
|
||||
string testString;
|
||||
|
||||
byteArray = Encoding.AtariEncoding.GetBytes(Pangrams.English);
|
||||
byteArray = Encoding.AtariEncoding.GetBytes(Pangrams.ENGLISH);
|
||||
testString = Encoding.AtariEncoding.GetString(byteArray);
|
||||
Assert.AreEqual(Pangrams.English, testString);
|
||||
Assert.AreEqual(Pangrams.ENGLISH, testString);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -79,21 +88,21 @@ namespace Claunia.Encoding.Tests
|
||||
{
|
||||
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(UpperLatin, testString);
|
||||
testString = Encoding.AtariEncoding.GetString(LowerLatinBytes);
|
||||
Assert.AreEqual(LowerLatin, 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(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]
|
||||
@@ -101,21 +110,21 @@ namespace Claunia.Encoding.Tests
|
||||
{
|
||||
byte[] byteArray;
|
||||
|
||||
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(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(Graphics);
|
||||
Assert.AreEqual(GraphicsBytes, byteArray);
|
||||
byteArray = Encoding.AtariEncoding.GetBytes(Arrows);
|
||||
Assert.AreEqual(ArrowsBytes, byteArray);
|
||||
byteArray = Encoding.AtariEncoding.GetBytes(Decks);
|
||||
Assert.AreEqual(DecksBytes, byteArray);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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
|
||||
@@ -29,203 +29,230 @@ using NUnit.Framework;
|
||||
namespace Claunia.Encoding.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class AtariST
|
||||
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
|
||||
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 =
|
||||
const string DIGITS = "0123456789";
|
||||
readonly byte[] _digitsBytes =
|
||||
{
|
||||
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
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39
|
||||
};
|
||||
const string LowerLatin = "abcdefghijklmnopqrstuvwxyz";
|
||||
readonly byte[] LowerLatinBytes =
|
||||
const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
readonly byte[] _upperLatinBytes =
|
||||
{
|
||||
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
|
||||
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 =
|
||||
const string SPANISH = "¡¿áéíóúüñÉÜÑ";
|
||||
readonly byte[] _spanishBytes =
|
||||
{
|
||||
0x82, 0x90, 0x85, 0x8A, 0x97, 0xB6, 0x83, 0x88, 0x8C, 0x93, 0x96, 0x89, 0x8B, 0x81, 0x98, 0x87, 0x80,
|
||||
0xB4, 0xB5, 0x91, 0x92
|
||||
0xAD, 0xA8, 0xA0, 0x82, 0xA1, 0xA2, 0xA3, 0x81, 0xA4, 0x90, 0x9A, 0xA5
|
||||
};
|
||||
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 =
|
||||
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 =
|
||||
const string DUTCH = "ijIJ";
|
||||
readonly byte[] _dutchBytes =
|
||||
{
|
||||
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
|
||||
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 Greek = "αβΓπΣσµτΦΘΩδ¯";
|
||||
readonly byte[] GreekBytes = {0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xFF};
|
||||
|
||||
const string Typographic = "ªº«»¨´†¶©®™§°∙·";
|
||||
readonly byte[] TypographicBytes =
|
||||
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 =
|
||||
const string CURRENCY = "¢£¥ƒ";
|
||||
readonly byte[] _currencyBytes =
|
||||
{
|
||||
0xA9, 0xAA, 0xAB, 0xAC, 0xDE, 0xDF, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6,
|
||||
0xF7, 0xFB, 0xFC, 0xFD, 0xFE
|
||||
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
|
||||
};
|
||||
const string Symbols = "⇧⇩⇨⇦❎✓♪ə";
|
||||
readonly byte[] SymbolsBytes = {0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x0B, 0x1A};
|
||||
|
||||
[Test]
|
||||
public void AtariSTPangrams()
|
||||
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);
|
||||
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()
|
||||
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(UpperLatin, testString);
|
||||
testString = Encoding.AtariSTEncoding.GetString(LowerLatinBytes);
|
||||
Assert.AreEqual(LowerLatin, 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(_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);
|
||||
|
||||
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);*/
|
||||
}
|
||||
|
||||
// TODO: 0x09 => U+1F552, 0x0A => U+1F514
|
||||
/*const string SymbolsUnicode32 = "\ud83d\udd52\ud83d\udd14";
|
||||
readonly byte[] SymbolsUnicode32Bytes = { 0x09, 0x0A };*/
|
||||
|
||||
[Test]
|
||||
public void UnicodeToAtariST()
|
||||
public void UnicodeToAtariSt()
|
||||
{
|
||||
byte[] byteArray;
|
||||
|
||||
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);
|
||||
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(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(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(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);
|
||||
|
||||
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);*/
|
||||
|
||||
@@ -1,47 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\NUnit.3.11.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" />
|
||||
<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.0</TargetFrameworkVersion>
|
||||
<ReleaseVersion>1.7</ReleaseVersion>
|
||||
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
|
||||
<ReleaseVersion>1.9</ReleaseVersion>
|
||||
</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="nunit.framework, Version=3.11.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb">
|
||||
<HintPath>..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="LisaRoman.cs" />
|
||||
<Compile Include="ATASCII.cs" />
|
||||
<Compile Include="AtariST.cs" />
|
||||
<Compile Include="GetEncs.cs" />
|
||||
<Compile Include="Radix50.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Claunia.Encoding\Claunia.Encoding.csproj">
|
||||
<Project>{85DA90BC-9F49-4579-B4D1-4FF2D5925D7F}</Project>
|
||||
@@ -49,13 +14,7 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="NUnit" Version="3.13.2" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.11.0\build\NUnit.props'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2017-2019 Natalia Portillo
|
||||
// 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
|
||||
@@ -33,6 +33,7 @@ namespace Claunia.Encoding.Tests
|
||||
public class GetEncs
|
||||
{
|
||||
[Test]
|
||||
|
||||
// Well basically this is taken from MSDN's documentation :p
|
||||
public void GetAllEncs()
|
||||
{
|
||||
@@ -47,21 +48,23 @@ namespace Claunia.Encoding.Tests
|
||||
{
|
||||
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.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("shift_jis");
|
||||
System.Text.Encoding e = Encoding.GetEncoding("iso8859-1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
// Well basically this is taken from MSDN's documentation :p
|
||||
public void GetInternalEncoding()
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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
|
||||
@@ -31,58 +31,73 @@ namespace Claunia.Encoding.Tests
|
||||
[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
|
||||
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 =
|
||||
const string DIGITS = "0123456789";
|
||||
readonly byte[] _digitsBytes =
|
||||
{
|
||||
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
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39
|
||||
};
|
||||
const string LowerLatin = "abcdefghijklmnopqrstuvwxyz";
|
||||
readonly byte[] LowerLatinBytes =
|
||||
const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
readonly byte[] _upperLatinBytes =
|
||||
{
|
||||
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
|
||||
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 =
|
||||
const string SPANISH = "¡¿áéíóúüñÉÜÑ";
|
||||
readonly byte[] _spanishBytes =
|
||||
{
|
||||
0x8E, 0x83, 0x88, 0x8F, 0x9D, 0xCB, 0x89, 0x90, 0x94, 0x99, 0x9E, 0x91, 0x95, 0x9F, 0xD8, 0x8D, 0x82,
|
||||
0xCF, 0xCE, 0xBE, 0xAE
|
||||
0xC1, 0xC0, 0x87, 0x8E, 0x92, 0x97, 0x9C, 0x9F, 0x96, 0x83, 0x86, 0x84
|
||||
};
|
||||
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 =
|
||||
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 =
|
||||
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
|
||||
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 =
|
||||
const string CURRENCY = "¢£¥";
|
||||
readonly byte[] _currencyBytes =
|
||||
{
|
||||
0xAD, 0xB0, 0xB1, 0xB2, 0xB3, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBD, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6,
|
||||
0xD6, 0xD7
|
||||
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]
|
||||
@@ -91,45 +106,45 @@ namespace Claunia.Encoding.Tests
|
||||
byte[] byteArray;
|
||||
string testString;
|
||||
|
||||
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Basque);
|
||||
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.BASQUE);
|
||||
testString = Encoding.LisaEncoding.GetString(byteArray);
|
||||
Assert.AreEqual(Pangrams.Basque, testString);
|
||||
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Breton);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
Assert.AreEqual(Pangrams.SPANISH, testString);
|
||||
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.SWEDISH);
|
||||
testString = Encoding.LisaEncoding.GetString(byteArray);
|
||||
Assert.AreEqual(Pangrams.Swedish, testString);
|
||||
Assert.AreEqual(Pangrams.SWEDISH, testString);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -137,32 +152,32 @@ namespace Claunia.Encoding.Tests
|
||||
{
|
||||
string 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(_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);
|
||||
|
||||
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(_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(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(_typographicBytes);
|
||||
Assert.AreEqual(TYPOGRAPHIC, testString);
|
||||
testString = Encoding.LisaEncoding.GetString(_currencyBytes);
|
||||
Assert.AreEqual(CURRENCY, testString);
|
||||
testString = Encoding.LisaEncoding.GetString(_mathematicsBytes);
|
||||
Assert.AreEqual(MATHEMATICS, testString);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -170,32 +185,32 @@ namespace Claunia.Encoding.Tests
|
||||
{
|
||||
byte[] byteArray;
|
||||
|
||||
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(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);
|
||||
|
||||
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(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(Typographic);
|
||||
Assert.AreEqual(TypographicBytes, byteArray);
|
||||
byteArray = Encoding.LisaEncoding.GetBytes(Currency);
|
||||
Assert.AreEqual(CurrencyBytes, byteArray);
|
||||
byteArray = Encoding.LisaEncoding.GetBytes(Mathematics);
|
||||
Assert.AreEqual(MathematicsBytes, byteArray);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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
|
||||
@@ -31,26 +31,29 @@ namespace Claunia.Encoding.Tests
|
||||
[TestFixture]
|
||||
public class Radix50
|
||||
{
|
||||
const string Punctuations = " .$%";
|
||||
readonly byte[] PunctuationsBytes = {0b00000001, 0b11000110, 0b11011101};
|
||||
const string Digits = "0123456789";
|
||||
readonly byte[] DigitsBytes =
|
||||
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 UpperLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
readonly byte[] UpperLatinBytes =
|
||||
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
|
||||
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 SentencePadded = "THIS IS A TEST$ "; // It gets space padded when decoding is not multiple
|
||||
readonly byte[] SentenceBytes =
|
||||
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
|
||||
0b01010000, 0b10000010, 0b01010011, 0b00000000, 0b10010100, 0b11000000, 0b00000100, 0b00000101, 0b00000101,
|
||||
0b01001101, 0b01000110, 0b11000000
|
||||
};
|
||||
|
||||
[Test]
|
||||
@@ -58,14 +61,14 @@ namespace Claunia.Encoding.Tests
|
||||
{
|
||||
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(UpperLatin, testString);
|
||||
testString = Encoding.Radix50Encoding.GetString(SentenceBytes);
|
||||
Assert.AreEqual(SentencePadded, 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]
|
||||
@@ -73,14 +76,14 @@ namespace Claunia.Encoding.Tests
|
||||
{
|
||||
byte[] byteArray;
|
||||
|
||||
byteArray = Encoding.Radix50Encoding.GetBytes(Punctuations);
|
||||
Assert.AreEqual(PunctuationsBytes, byteArray);
|
||||
byteArray = Encoding.Radix50Encoding.GetBytes(Digits);
|
||||
Assert.AreEqual(DigitsBytes, byteArray);
|
||||
byteArray = Encoding.Radix50Encoding.GetBytes(UpperLatin);
|
||||
Assert.AreEqual(UpperLatinBytes, byteArray);
|
||||
byteArray = Encoding.Radix50Encoding.GetBytes(Sentence);
|
||||
Assert.AreEqual(SentenceBytes, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NUnit" version="3.11.0" targetFramework="net45" />
|
||||
</packages>
|
||||
3
Claunia.Encoding.sln.DotSettings
Normal file
3
Claunia.Encoding.sln.DotSettings
Normal 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>
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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,583 +24,319 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Claunia.Encoding
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an ATARI Standard Code for Information Interchange character encoding of Unicode characters.
|
||||
/// </summary>
|
||||
public class ATASCII : Encoding
|
||||
/// <summary>Represents an ATARI Standard Code for Information Interchange character encoding of Unicode characters.</summary>
|
||||
public class Atascii : SingleByteEncodingWithRunes
|
||||
{
|
||||
const string _bodyname = "atascii";
|
||||
const int _codepage = 0;
|
||||
const string _encodingname = "Atari Standard Code for Information Interchange";
|
||||
const string _headername = "atascii";
|
||||
const string _webname = "";
|
||||
const int _windowsCodepage = 0;
|
||||
/// <inheritdoc />
|
||||
public override string BodyName => "atascii";
|
||||
/// <inheritdoc />
|
||||
public override int CodePage => 0;
|
||||
/// <inheritdoc />
|
||||
public override string EncodingName => "Atari Standard Code for Information Interchange";
|
||||
/// <inheritdoc />
|
||||
public override string HeaderName => "atascii";
|
||||
/// <inheritdoc />
|
||||
public override string WebName => "";
|
||||
/// <inheritdoc />
|
||||
public override 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;
|
||||
/// <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 ATASCII to Unicode character map.
|
||||
/// </summary>
|
||||
static readonly char[] ATASCIITable =
|
||||
/// <summary>The ATASCII to Unicode character map.</summary>
|
||||
protected override Rune[] CharTable => new[]
|
||||
{
|
||||
// 0x00
|
||||
'\u2665', '\u251C', '\uFFFD', '\u2518', '\u2524', '\u2510', '\u2571', '\u2572',
|
||||
new Rune(0x2665), new Rune(0x251C), new Rune(0x1FB87), new Rune(0x2518), new Rune(0x2524), new Rune(0x2510),
|
||||
new Rune(0x2571), new Rune(0x2572),
|
||||
|
||||
// 0x08
|
||||
'\u25E2', '\u2597', '\u25E3', '\u259D', '\u2598', '\uFFFD', '\u2582', '\u2596',
|
||||
new Rune(0x25E2), new Rune(0x2597), new Rune(0x25E3), new Rune(0x259D), new Rune(0x2598), new Rune(0x1FB82),
|
||||
new Rune(0x2582), new Rune(0x2596),
|
||||
|
||||
// 0x10
|
||||
'\u2663', '\u250C', '\u2500', '\u253C', '\u25CF', '\u2584', '\u258E', '\u252C',
|
||||
new Rune(0x2663), new Rune(0x250C), new Rune(0x2500), new Rune(0x253C), new Rune(0x25CF), new Rune(0x2584),
|
||||
new Rune(0x258E), new Rune(0x252C),
|
||||
|
||||
// 0x18
|
||||
'\u2534', '\u258C', '\u2514', '\u001B', '\u2191', '\u2193', '\u2190', '\u2192',
|
||||
new Rune(0x2534), new Rune(0x258C), new Rune(0x2514), new Rune(0x001B), new Rune(0x2191), new Rune(0x2193),
|
||||
new Rune(0x2190), new Rune(0x2192),
|
||||
|
||||
// 0x20
|
||||
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
|
||||
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
|
||||
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
|
||||
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
|
||||
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
|
||||
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
|
||||
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
|
||||
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
|
||||
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
|
||||
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
|
||||
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
|
||||
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
|
||||
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
|
||||
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
|
||||
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
|
||||
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
|
||||
'\u2666', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
|
||||
new Rune(0x2666), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065),
|
||||
new Rune(0x0066), new Rune(0x0067),
|
||||
|
||||
// 0x68
|
||||
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
|
||||
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
|
||||
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
|
||||
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
|
||||
'\u0078', '\u0079', '\u007A', '\u2660', '\u007C', '\u21B0', '\u25C0', '\u25B6',
|
||||
new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x2660), new Rune(0x007C), new Rune(0x1F8B0),
|
||||
new Rune(0x25C0), new Rune(0x25B6),
|
||||
|
||||
// 0x80
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
new Rune(0x0000), new Rune(0x0000), new Rune(0x258A), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
|
||||
new Rune(0x0000), new Rune(0x0000),
|
||||
|
||||
// 0x88
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
new Rune(0x25E4), new Rune(0x259B), new Rune(0x25E5), new Rune(0x2599), new Rune(0x259F), new Rune(0x2586),
|
||||
new Rune(0x0000), new Rune(0x259C),
|
||||
|
||||
// 0x90
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x25D8), new Rune(0x2580),
|
||||
new Rune(0x0000), new Rune(0x0000),
|
||||
|
||||
// 0x98
|
||||
'\u0000', '\u0000', '\u0000', '\u000D', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
new Rune(0x0000), new Rune(0x2590), new Rune(0x0000), new Rune(0x000D), new Rune(0x0000), new Rune(0x0000),
|
||||
new Rune(0x0000), new Rune(0x0000),
|
||||
|
||||
// 0xA0
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
new Rune(0x2588), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
|
||||
new Rune(0x0000), new Rune(0x0000),
|
||||
|
||||
// 0xA8
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
|
||||
new Rune(0x0000), new Rune(0x0000),
|
||||
|
||||
// 0xB0
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
|
||||
new Rune(0x0000), new Rune(0x0000),
|
||||
|
||||
// 0xB8
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
|
||||
new Rune(0x0000), new Rune(0x0000),
|
||||
|
||||
// 0xC0
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
|
||||
new Rune(0x0000), new Rune(0x0000),
|
||||
|
||||
// 0xD8
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
|
||||
new Rune(0x0000), new Rune(0x0000),
|
||||
|
||||
// 0xE0
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
|
||||
new Rune(0x0000), new Rune(0x0000),
|
||||
|
||||
// 0xE8
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
|
||||
new Rune(0x0000), new Rune(0x0000),
|
||||
|
||||
// 0xF0
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000),
|
||||
new Rune(0x0000), new Rune(0x0000),
|
||||
|
||||
// 0xF8
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0007', '\u0000', '\u0000'
|
||||
new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0007),
|
||||
new Rune(0x0000), new Rune(0x0000)
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserDisplay => browserDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserSave => browserSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsDisplay => mailNewsDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsSave => mailNewsSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding is read-only.
|
||||
/// </summary>
|
||||
/// <value>The is single byte.</value>
|
||||
public override bool IsReadOnly => readOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding uses single-byte code points.
|
||||
/// </summary>
|
||||
public override bool IsSingleByte => singleByte;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the code page identifier of the current Encoding.
|
||||
/// </summary>
|
||||
public override int CodePage => _codepage;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent body tags
|
||||
/// </summary>
|
||||
public override string BodyName => _bodyname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent header tags
|
||||
/// </summary>
|
||||
public override string HeaderName => _headername;
|
||||
|
||||
/// <summary>
|
||||
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
|
||||
/// </summary>
|
||||
public override string WebName => _webname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the human-readable description of the current encoding.
|
||||
/// </summary>
|
||||
public override string EncodingName => _encodingname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
|
||||
/// </summary>
|
||||
public override int WindowsCodePage => _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) =>
|
||||
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 string(GetChars(bytes, index, count));
|
||||
|
||||
/// <summary>
|
||||
/// Converts a ATASCII character to an Unicode character
|
||||
/// </summary>
|
||||
/// <returns>Unicode character.</returns>
|
||||
/// <param name="character">ATASCII character.</param>
|
||||
static char GetChar(byte character) => ATASCIITable[character];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Unicode character to an ATASCII character
|
||||
/// </summary>
|
||||
/// <summary>Converts a Unicode character to an ATASCII character</summary>
|
||||
/// <returns>ATASCII character.</returns>
|
||||
/// <param name="character">Unicode character.</param>
|
||||
static byte GetByte(char character)
|
||||
private protected override byte GetByte(Rune character) => character.Value switch
|
||||
{
|
||||
switch(character)
|
||||
{
|
||||
case '\u2665': return 0x00;
|
||||
case '\u251C': return 0x01;
|
||||
case '\u2518': return 0x03;
|
||||
case '\u2524': return 0x04;
|
||||
case '\u2510': return 0x05;
|
||||
case '\u2571': return 0x06;
|
||||
case '\u2572': return 0x07;
|
||||
case '\u25E2': return 0x08;
|
||||
case '\u2597': return 0x09;
|
||||
case '\u25E3': return 0x0A;
|
||||
case '\u259D': return 0x0B;
|
||||
case '\u2598': return 0x0C;
|
||||
case '\u2582': return 0x0E;
|
||||
case '\u2596': return 0x0F;
|
||||
case '\u2663': return 0x10;
|
||||
case '\u250C': return 0x11;
|
||||
case '\u2500': return 0x12;
|
||||
case '\u253C': return 0x13;
|
||||
case '\u25CF': return 0x14;
|
||||
case '\u2584': return 0x15;
|
||||
case '\u258E': return 0x16;
|
||||
case '\u252C': return 0x17;
|
||||
case '\u2534': return 0x18;
|
||||
case '\u258C': return 0x19;
|
||||
case '\u2514': return 0x1A;
|
||||
case '\u001B': return 0x1B;
|
||||
case '\u2191': return 0x1C;
|
||||
case '\u2193': return 0x1D;
|
||||
case '\u2190': return 0x1E;
|
||||
case '\u2192': return 0x1F;
|
||||
case '\u0020': return 0x20;
|
||||
case '\u0021': return 0x21;
|
||||
case '\u0022': return 0x22;
|
||||
case '\u0023': return 0x23;
|
||||
case '\u0024': return 0x24;
|
||||
case '\u0025': return 0x25;
|
||||
case '\u0026': return 0x26;
|
||||
case '\u0027': return 0x27;
|
||||
case '\u0028': return 0x28;
|
||||
case '\u0029': return 0x29;
|
||||
case '\u002A': return 0x2A;
|
||||
case '\u002B': return 0x2B;
|
||||
case '\u002C': return 0x2C;
|
||||
case '\u002D': return 0x2D;
|
||||
case '\u002E': return 0x2E;
|
||||
case '\u002F': return 0x2F;
|
||||
case '\u0030': return 0x30;
|
||||
case '\u0031': return 0x31;
|
||||
case '\u0032': return 0x32;
|
||||
case '\u0033': return 0x33;
|
||||
case '\u0034': return 0x34;
|
||||
case '\u0035': return 0x35;
|
||||
case '\u0036': return 0x36;
|
||||
case '\u0037': return 0x37;
|
||||
case '\u0038': return 0x38;
|
||||
case '\u0039': return 0x39;
|
||||
case '\u003A': return 0x3A;
|
||||
case '\u003B': return 0x3B;
|
||||
case '\u003C': return 0x3C;
|
||||
case '\u003D': return 0x3D;
|
||||
case '\u003E': return 0x3E;
|
||||
case '\u003F': return 0x3F;
|
||||
case '\u0040': return 0x40;
|
||||
case '\u0041': return 0x41;
|
||||
case '\u0042': return 0x42;
|
||||
case '\u0043': return 0x43;
|
||||
case '\u0044': return 0x44;
|
||||
case '\u0045': return 0x45;
|
||||
case '\u0046': return 0x46;
|
||||
case '\u0047': return 0x47;
|
||||
case '\u0048': return 0x48;
|
||||
case '\u0049': return 0x49;
|
||||
case '\u004A': return 0x4A;
|
||||
case '\u004B': return 0x4B;
|
||||
case '\u004C': return 0x4C;
|
||||
case '\u004D': return 0x4D;
|
||||
case '\u004E': return 0x4E;
|
||||
case '\u004F': return 0x4F;
|
||||
case '\u0050': return 0x50;
|
||||
case '\u0051': return 0x51;
|
||||
case '\u0052': return 0x52;
|
||||
case '\u0053': return 0x53;
|
||||
case '\u0054': return 0x54;
|
||||
case '\u0055': return 0x55;
|
||||
case '\u0056': return 0x56;
|
||||
case '\u0057': return 0x57;
|
||||
case '\u0058': return 0x58;
|
||||
case '\u0059': return 0x59;
|
||||
case '\u005A': return 0x5A;
|
||||
case '\u005B': return 0x5B;
|
||||
case '\u005C': return 0x5C;
|
||||
case '\u005D': return 0x5D;
|
||||
case '\u005E': return 0x5E;
|
||||
case '\u005F': return 0x5F;
|
||||
case '\u2666': return 0x60;
|
||||
case '\u0061': return 0x61;
|
||||
case '\u0062': return 0x62;
|
||||
case '\u0063': return 0x63;
|
||||
case '\u0064': return 0x64;
|
||||
case '\u0065': return 0x65;
|
||||
case '\u0066': return 0x66;
|
||||
case '\u0067': return 0x67;
|
||||
case '\u0068': return 0x68;
|
||||
case '\u0069': return 0x69;
|
||||
case '\u006A': return 0x6A;
|
||||
case '\u006B': return 0x6B;
|
||||
case '\u006C': return 0x6C;
|
||||
case '\u006D': return 0x6D;
|
||||
case '\u006E': return 0x6E;
|
||||
case '\u006F': return 0x6F;
|
||||
case '\u0070': return 0x70;
|
||||
case '\u0071': return 0x71;
|
||||
case '\u0072': return 0x72;
|
||||
case '\u0073': return 0x73;
|
||||
case '\u0074': return 0x74;
|
||||
case '\u0075': return 0x75;
|
||||
case '\u0076': return 0x76;
|
||||
case '\u0077': return 0x77;
|
||||
case '\u0078': return 0x78;
|
||||
case '\u0079': return 0x79;
|
||||
case '\u007A': return 0x7A;
|
||||
case '\u2660': return 0x7B;
|
||||
case '\u007C': return 0x7C;
|
||||
case '\u21B0': return 0x7D;
|
||||
case '\u25C0': return 0x7E;
|
||||
case '\u25B6': return 0x7F;
|
||||
case '\u000D': return 0x9B;
|
||||
case '\u0007': return 0xFD;
|
||||
default:
|
||||
// Fallback to '?'
|
||||
return 0x3F;
|
||||
}
|
||||
}
|
||||
0x2665 => 0x00,
|
||||
0x251C => 0x01,
|
||||
0x1FB87 => 0x02,
|
||||
0x2518 => 0x03,
|
||||
0x2524 => 0x04,
|
||||
0x2510 => 0x05,
|
||||
0x2571 => 0x06,
|
||||
0x2572 => 0x07,
|
||||
0x25E2 => 0x08,
|
||||
0x2597 => 0x09,
|
||||
0x25E3 => 0x0A,
|
||||
0x259D => 0x0B,
|
||||
0x2598 => 0x0C,
|
||||
0x1FB82 => 0x0D,
|
||||
0x2582 => 0x0E,
|
||||
0x2596 => 0x0F,
|
||||
0x2663 => 0x10,
|
||||
0x250C => 0x11,
|
||||
0x2500 => 0x12,
|
||||
0x253C => 0x13,
|
||||
0x25CF => 0x14,
|
||||
0x2584 => 0x15,
|
||||
0x258E => 0x16,
|
||||
0x252C => 0x17,
|
||||
0x2534 => 0x18,
|
||||
0x258C => 0x19,
|
||||
0x2514 => 0x1A,
|
||||
0x001B => 0x1B,
|
||||
0x2191 => 0x1C,
|
||||
0x2193 => 0x1D,
|
||||
0x2190 => 0x1E,
|
||||
0x2192 => 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,
|
||||
0x2666 => 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,
|
||||
0x2660 => 0x7B,
|
||||
0x007C => 0x7C,
|
||||
0x1F8B0 => 0x7D,
|
||||
0x25C0 => 0x7E,
|
||||
0x25B6 => 0x7F,
|
||||
0x258A => 0x82,
|
||||
0x25E4 => 0x88,
|
||||
0x259B => 0x89,
|
||||
0x25E5 => 0x8A,
|
||||
0x2599 => 0x8B,
|
||||
0x259F => 0x8C,
|
||||
0x2586 => 0x8D,
|
||||
0x259C => 0x8F,
|
||||
0x25D8 => 0x94,
|
||||
0x2580 => 0x95,
|
||||
0x2590 => 0x99,
|
||||
0x000D => 0x9B,
|
||||
0x2588 => 0xA0,
|
||||
0x0007 => 0xFD,
|
||||
_ => 0x3F
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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,519 +24,207 @@
|
||||
// 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 Apple II character encoding of Unicode characters.
|
||||
/// </summary>
|
||||
public class Apple2 : Encoding
|
||||
/// <summary>Represents an Apple II character encoding of Unicode characters.</summary>
|
||||
public sealed class Apple2 : SingleByteEncoding
|
||||
{
|
||||
const string _bodyname = "apple2";
|
||||
const int _codepage = 0;
|
||||
const string _encodingname = "Western European (Apple II)";
|
||||
const string _headername = "apple2";
|
||||
const string _webname = "";
|
||||
const int _windowsCodepage = 0;
|
||||
/// <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;
|
||||
|
||||
const bool browserDisplay = false;
|
||||
const bool browserSave = false;
|
||||
const bool mailNewsDisplay = false;
|
||||
const bool mailNewsSave = false;
|
||||
const bool readOnly = false;
|
||||
const bool singleByte = true;
|
||||
/// <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>
|
||||
static readonly char[] Apple2Table =
|
||||
/// <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>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserDisplay => browserDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserSave => browserSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsDisplay => mailNewsDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsSave => mailNewsSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding is read-only.
|
||||
/// </summary>
|
||||
/// <value>The is single byte.</value>
|
||||
public override bool IsReadOnly => readOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding uses single-byte code points.
|
||||
/// </summary>
|
||||
public override bool IsSingleByte => singleByte;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the code page identifier of the current Encoding.
|
||||
/// </summary>
|
||||
public override int CodePage => _codepage;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent body tags
|
||||
/// </summary>
|
||||
public override string BodyName => _bodyname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent header tags
|
||||
/// </summary>
|
||||
public override string HeaderName => _headername;
|
||||
|
||||
/// <summary>
|
||||
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
|
||||
/// </summary>
|
||||
public override string WebName => _webname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the human-readable description of the current encoding.
|
||||
/// </summary>
|
||||
public override string EncodingName => _encodingname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
|
||||
/// </summary>
|
||||
public override int WindowsCodePage => _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) =>
|
||||
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 string(GetChars(bytes, index, count));
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Apple II character to an Unicode character
|
||||
/// </summary>
|
||||
/// <returns>Unicode character.</returns>
|
||||
/// <param name="character">Apple II character.</param>
|
||||
static char GetChar(byte character) => Apple2Table[character];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Unicode character to an Apple II character
|
||||
/// </summary>
|
||||
/// <summary>Converts a Unicode character to an Apple II character</summary>
|
||||
/// <returns>Apple II character.</returns>
|
||||
/// <param name="character">Unicode character.</param>
|
||||
static byte GetByte(char character)
|
||||
private protected override byte GetByte(char character) => character switch
|
||||
{
|
||||
switch(character)
|
||||
{
|
||||
case '\u0020': return 0x20;
|
||||
case '\u0021': return 0x21;
|
||||
case '\u0022': return 0x22;
|
||||
case '\u0023': return 0x23;
|
||||
case '\u0024': return 0x24;
|
||||
case '\u0025': return 0x25;
|
||||
case '\u0026': return 0x26;
|
||||
case '\u0027': return 0x27;
|
||||
case '\u0028': return 0x28;
|
||||
case '\u0029': return 0x29;
|
||||
case '\u002A': return 0x2A;
|
||||
case '\u002B': return 0x2B;
|
||||
case '\u002C': return 0x2C;
|
||||
case '\u002D': return 0x2D;
|
||||
case '\u002E': return 0x2E;
|
||||
case '\u002F': return 0x2F;
|
||||
case '\u0030': return 0x30;
|
||||
case '\u0031': return 0x31;
|
||||
case '\u0032': return 0x32;
|
||||
case '\u0033': return 0x33;
|
||||
case '\u0034': return 0x34;
|
||||
case '\u0035': return 0x35;
|
||||
case '\u0036': return 0x36;
|
||||
case '\u0037': return 0x37;
|
||||
case '\u0038': return 0x38;
|
||||
case '\u0039': return 0x39;
|
||||
case '\u003A': return 0x3A;
|
||||
case '\u003B': return 0x3B;
|
||||
case '\u003C': return 0x3C;
|
||||
case '\u003D': return 0x3D;
|
||||
case '\u003E': return 0x3E;
|
||||
case '\u003F': return 0x3F;
|
||||
case '\u0040': return 0x40;
|
||||
case '\u0041': return 0x41;
|
||||
case '\u0042': return 0x42;
|
||||
case '\u0043': return 0x43;
|
||||
case '\u0044': return 0x44;
|
||||
case '\u0045': return 0x45;
|
||||
case '\u0046': return 0x46;
|
||||
case '\u0047': return 0x47;
|
||||
case '\u0048': return 0x48;
|
||||
case '\u0049': return 0x49;
|
||||
case '\u004A': return 0x4A;
|
||||
case '\u004B': return 0x4B;
|
||||
case '\u004C': return 0x4C;
|
||||
case '\u004D': return 0x4D;
|
||||
case '\u004E': return 0x4E;
|
||||
case '\u004F': return 0x4F;
|
||||
case '\u0050': return 0x50;
|
||||
case '\u0051': return 0x51;
|
||||
case '\u0052': return 0x52;
|
||||
case '\u0053': return 0x53;
|
||||
case '\u0054': return 0x54;
|
||||
case '\u0055': return 0x55;
|
||||
case '\u0056': return 0x56;
|
||||
case '\u0057': return 0x57;
|
||||
case '\u0058': return 0x58;
|
||||
case '\u0059': return 0x59;
|
||||
case '\u005A': return 0x5A;
|
||||
case '\u005B': return 0x5B;
|
||||
case '\u005C': return 0x5C;
|
||||
case '\u005D': return 0x5D;
|
||||
case '\u005E': return 0x5E;
|
||||
case '\u005F': return 0x5F;
|
||||
default:
|
||||
// Fallback to '?'
|
||||
return 0x3F;
|
||||
}
|
||||
}
|
||||
'\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
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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,594 +24,337 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Claunia.Encoding
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an Apple IIc character encoding of Unicode characters.
|
||||
/// </summary>
|
||||
public class Apple2c : Encoding
|
||||
/// <summary>Represents an Apple IIc character encoding of Unicode characters.</summary>
|
||||
public sealed class Apple2C : SingleByteEncodingWithRunes
|
||||
{
|
||||
const string _bodyname = "apple2c";
|
||||
const int _codepage = 0;
|
||||
const string _encodingname = "Western European (Apple IIc)";
|
||||
const string _headername = "apple2c";
|
||||
const string _webname = "";
|
||||
const int _windowsCodepage = 0;
|
||||
/// <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;
|
||||
|
||||
const bool browserDisplay = false;
|
||||
const bool browserSave = false;
|
||||
const bool mailNewsDisplay = false;
|
||||
const bool mailNewsSave = false;
|
||||
const bool readOnly = true;
|
||||
const bool singleByte = true;
|
||||
/// <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>
|
||||
static readonly char[] Apple2cTable =
|
||||
/// <summary>The Apple IIc to Unicode character map. Inverted screen characters are mapped to normal characters.</summary>
|
||||
protected override Rune[] CharTable => new[]
|
||||
{
|
||||
// 0x00
|
||||
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
|
||||
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
|
||||
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
|
||||
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
|
||||
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
|
||||
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
|
||||
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
|
||||
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
|
||||
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
|
||||
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
|
||||
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
|
||||
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
|
||||
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
|
||||
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
|
||||
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
|
||||
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
|
||||
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
|
||||
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
|
||||
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
|
||||
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
|
||||
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
|
||||
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
|
||||
'\u0058', '\u0059', '\u005A', '\u005B', '\u00A3', '\u005D', '\u005E', '\u005F',
|
||||
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
|
||||
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
|
||||
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
|
||||
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
|
||||
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
|
||||
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
|
||||
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
|
||||
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
|
||||
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
|
||||
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
|
||||
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
|
||||
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
|
||||
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
|
||||
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
|
||||
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
|
||||
'\u0058', '\u0059', '\u005A', '\u005B', '\u00A3', '\u005D', '\u005E', '\u0020',
|
||||
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
|
||||
'\u2588', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
|
||||
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
|
||||
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
|
||||
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
|
||||
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
|
||||
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
|
||||
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u231B', '\u2713', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u2190', '\u2026', '\u2193', '\u2191', '\u0000', '\u21B5', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u2192', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u25c6', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
|
||||
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
|
||||
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
|
||||
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
|
||||
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
|
||||
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
|
||||
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F'
|
||||
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>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserDisplay => browserDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserSave => browserSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsDisplay => mailNewsDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsSave => mailNewsSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding is read-only.
|
||||
/// </summary>
|
||||
/// <value>The is single byte.</value>
|
||||
public override bool IsReadOnly => readOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding uses single-byte code points.
|
||||
/// </summary>
|
||||
public override bool IsSingleByte => singleByte;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the code page identifier of the current Encoding.
|
||||
/// </summary>
|
||||
public override int CodePage => _codepage;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent body tags
|
||||
/// </summary>
|
||||
public override string BodyName => _bodyname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent header tags
|
||||
/// </summary>
|
||||
public override string HeaderName => _headername;
|
||||
|
||||
/// <summary>
|
||||
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
|
||||
/// </summary>
|
||||
public override string WebName => _webname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the human-readable description of the current encoding.
|
||||
/// </summary>
|
||||
public override string EncodingName => _encodingname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
|
||||
/// </summary>
|
||||
public override int WindowsCodePage => _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) =>
|
||||
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 string(GetChars(bytes, index, count));
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Apple IIc character to an Unicode character
|
||||
/// </summary>
|
||||
/// <returns>Unicode character.</returns>
|
||||
/// <param name="character">Apple IIc character.</param>
|
||||
static char GetChar(byte character) => Apple2cTable[character];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Unicode character to an Apple IIc character
|
||||
/// </summary>
|
||||
/// <summary>Converts a Unicode character to an Apple IIc character</summary>
|
||||
/// <returns>Apple IIc character.</returns>
|
||||
/// <param name="character">Unicode character.</param>
|
||||
static byte GetByte(char character)
|
||||
private protected override byte GetByte(Rune character) => character.Value switch
|
||||
{
|
||||
switch(character)
|
||||
{
|
||||
case '\u0000': return 0x00;
|
||||
case '\u0001': return 0x01;
|
||||
case '\u0002': return 0x02;
|
||||
case '\u0003': return 0x03;
|
||||
case '\u0004': return 0x04;
|
||||
case '\u0005': return 0x05;
|
||||
case '\u0006': return 0x06;
|
||||
case '\u0007': return 0x07;
|
||||
case '\u0008': return 0x08;
|
||||
case '\u0009': return 0x09;
|
||||
case '\u000A': return 0x0A;
|
||||
case '\u000B': return 0x0B;
|
||||
case '\u000C': return 0x0C;
|
||||
case '\u000D': return 0x0D;
|
||||
case '\u000E': return 0x0E;
|
||||
case '\u000F': return 0x0F;
|
||||
case '\u0010': return 0x10;
|
||||
case '\u0011': return 0x11;
|
||||
case '\u0012': return 0x12;
|
||||
case '\u0013': return 0x13;
|
||||
case '\u0014': return 0x14;
|
||||
case '\u0015': return 0x15;
|
||||
case '\u0016': return 0x16;
|
||||
case '\u0017': return 0x17;
|
||||
case '\u0018': return 0x18;
|
||||
case '\u0019': return 0x19;
|
||||
case '\u001A': return 0x1A;
|
||||
case '\u001B': return 0x1B;
|
||||
case '\u001C': return 0x1C;
|
||||
case '\u001D': return 0x1D;
|
||||
case '\u001E': return 0x1E;
|
||||
case '\u001F': return 0x1F;
|
||||
case '\u0020': return 0x20;
|
||||
case '\u0021': return 0x21;
|
||||
case '\u0022': return 0x22;
|
||||
case '\u0023': return 0x23;
|
||||
case '\u0024': return 0x24;
|
||||
case '\u0025': return 0x25;
|
||||
case '\u0026': return 0x26;
|
||||
case '\u0027': return 0x27;
|
||||
case '\u0028': return 0x28;
|
||||
case '\u0029': return 0x29;
|
||||
case '\u002A': return 0x2A;
|
||||
case '\u002B': return 0x2B;
|
||||
case '\u002C': return 0x2C;
|
||||
case '\u002D': return 0x2D;
|
||||
case '\u002E': return 0x2E;
|
||||
case '\u002F': return 0x2F;
|
||||
case '\u0030': return 0x30;
|
||||
case '\u0031': return 0x31;
|
||||
case '\u0032': return 0x32;
|
||||
case '\u0033': return 0x33;
|
||||
case '\u0034': return 0x34;
|
||||
case '\u0035': return 0x35;
|
||||
case '\u0036': return 0x36;
|
||||
case '\u0037': return 0x37;
|
||||
case '\u0038': return 0x38;
|
||||
case '\u0039': return 0x39;
|
||||
case '\u003A': return 0x3A;
|
||||
case '\u003B': return 0x3B;
|
||||
case '\u003C': return 0x3C;
|
||||
case '\u003D': return 0x3D;
|
||||
case '\u003E': return 0x3E;
|
||||
case '\u003F': return 0x3F;
|
||||
case '\u0040': return 0x40;
|
||||
case '\u0041': return 0x41;
|
||||
case '\u0042': return 0x42;
|
||||
case '\u0043': return 0x43;
|
||||
case '\u0044': return 0x44;
|
||||
case '\u0045': return 0x45;
|
||||
case '\u0046': return 0x46;
|
||||
case '\u0047': return 0x47;
|
||||
case '\u0048': return 0x48;
|
||||
case '\u0049': return 0x49;
|
||||
case '\u004A': return 0x4A;
|
||||
case '\u004B': return 0x4B;
|
||||
case '\u004C': return 0x4C;
|
||||
case '\u004D': return 0x4D;
|
||||
case '\u004E': return 0x4E;
|
||||
case '\u004F': return 0x4F;
|
||||
case '\u0050': return 0x50;
|
||||
case '\u0051': return 0x51;
|
||||
case '\u0052': return 0x52;
|
||||
case '\u0053': return 0x53;
|
||||
case '\u0054': return 0x54;
|
||||
case '\u0055': return 0x55;
|
||||
case '\u0056': return 0x56;
|
||||
case '\u0057': return 0x57;
|
||||
case '\u0058': return 0x58;
|
||||
case '\u0059': return 0x59;
|
||||
case '\u005A': return 0x5A;
|
||||
case '\u005B': return 0x5B;
|
||||
case '\u00A3': return 0x5C;
|
||||
case '\u005D': return 0x5D;
|
||||
case '\u005E': return 0x5E;
|
||||
case '\u005F': return 0x5F;
|
||||
case '\u0060': return 0x60;
|
||||
case '\u0061': return 0x61;
|
||||
case '\u0062': return 0x62;
|
||||
case '\u0063': return 0x63;
|
||||
case '\u0064': return 0x64;
|
||||
case '\u0065': return 0x65;
|
||||
case '\u0066': return 0x66;
|
||||
case '\u0067': return 0x67;
|
||||
case '\u0068': return 0x68;
|
||||
case '\u0069': return 0x69;
|
||||
case '\u006A': return 0x6A;
|
||||
case '\u006B': return 0x6B;
|
||||
case '\u006C': return 0x6C;
|
||||
case '\u006D': return 0x6D;
|
||||
case '\u006E': return 0x6E;
|
||||
case '\u006F': return 0x6F;
|
||||
case '\u0070': return 0x70;
|
||||
case '\u0071': return 0x71;
|
||||
case '\u0072': return 0x72;
|
||||
case '\u0073': return 0x73;
|
||||
case '\u0074': return 0x74;
|
||||
case '\u0075': return 0x75;
|
||||
case '\u0076': return 0x76;
|
||||
case '\u0077': return 0x77;
|
||||
case '\u0078': return 0x78;
|
||||
case '\u0079': return 0x79;
|
||||
case '\u007A': return 0x7A;
|
||||
case '\u007B': return 0x7B;
|
||||
case '\u007C': return 0x7C;
|
||||
case '\u007D': return 0x7D;
|
||||
case '\u007E': return 0x7E;
|
||||
case '\u007F': return 0x7F;
|
||||
case '\u2588': return 0xA0;
|
||||
case '\u231B': return 0xC3;
|
||||
case '\u2713': return 0xC4;
|
||||
case '\u2190': return 0xC8;
|
||||
case '\u2026': return 0xC9;
|
||||
case '\u2193': return 0xCA;
|
||||
case '\u2191': return 0xCB;
|
||||
case '\u21B5': return 0xCD;
|
||||
case '\u2192': return 0xD5;
|
||||
case '\u25C6': return 0xDB;
|
||||
default:
|
||||
// Fallback to '?'
|
||||
return 0x3F;
|
||||
}
|
||||
}
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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,580 +24,268 @@
|
||||
// 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 Apple IIe character encoding of Unicode characters.
|
||||
/// </summary>
|
||||
public class Apple2e : Encoding
|
||||
/// <summary>Represents an Apple IIe character encoding of Unicode characters.</summary>
|
||||
public class Apple2E : SingleByteEncoding
|
||||
{
|
||||
const string _bodyname = "apple2e";
|
||||
const int _codepage = 0;
|
||||
const string _encodingname = "Western European (Apple IIe)";
|
||||
const string _headername = "apple2e";
|
||||
const string _webname = "";
|
||||
const int _windowsCodepage = 0;
|
||||
/// <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;
|
||||
|
||||
const bool browserDisplay = false;
|
||||
const bool browserSave = false;
|
||||
const bool mailNewsDisplay = false;
|
||||
const bool mailNewsSave = false;
|
||||
const bool readOnly = true;
|
||||
const bool singleByte = true;
|
||||
/// <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>
|
||||
static readonly char[] Apple2eTable =
|
||||
/// <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>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserDisplay => browserDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserSave => browserSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsDisplay => mailNewsDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsSave => mailNewsSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding is read-only.
|
||||
/// </summary>
|
||||
/// <value>The is single byte.</value>
|
||||
public override bool IsReadOnly => readOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding uses single-byte code points.
|
||||
/// </summary>
|
||||
public override bool IsSingleByte => singleByte;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the code page identifier of the current Encoding.
|
||||
/// </summary>
|
||||
public override int CodePage => _codepage;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent body tags
|
||||
/// </summary>
|
||||
public override string BodyName => _bodyname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent header tags
|
||||
/// </summary>
|
||||
public override string HeaderName => _headername;
|
||||
|
||||
/// <summary>
|
||||
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
|
||||
/// </summary>
|
||||
public override string WebName => _webname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the human-readable description of the current encoding.
|
||||
/// </summary>
|
||||
public override string EncodingName => _encodingname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
|
||||
/// </summary>
|
||||
public override int WindowsCodePage => _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) =>
|
||||
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 string(GetChars(bytes, index, count));
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Apple IIe character to an Unicode character
|
||||
/// </summary>
|
||||
/// <returns>Unicode character.</returns>
|
||||
/// <param name="character">Apple IIe character.</param>
|
||||
static char GetChar(byte character) => Apple2eTable[character];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Unicode character to an Apple IIe character
|
||||
/// </summary>
|
||||
/// <summary>Converts a Unicode character to an Apple IIe character</summary>
|
||||
/// <returns>Apple IIe character.</returns>
|
||||
/// <param name="character">Unicode character.</param>
|
||||
static byte GetByte(char character)
|
||||
private protected override byte GetByte(char character) => character switch
|
||||
{
|
||||
switch(character)
|
||||
{
|
||||
case '\u0020': return 0x00;
|
||||
case '\u0021': return 0x01;
|
||||
case '\u0022': return 0x02;
|
||||
case '\u0023': return 0x03;
|
||||
case '\u0024': return 0x04;
|
||||
case '\u0025': return 0x05;
|
||||
case '\u0026': return 0x06;
|
||||
case '\u0027': return 0x07;
|
||||
case '\u0028': return 0x08;
|
||||
case '\u0029': return 0x09;
|
||||
case '\u002A': return 0x0A;
|
||||
case '\u002B': return 0x0B;
|
||||
case '\u002C': return 0x0C;
|
||||
case '\u002D': return 0x0D;
|
||||
case '\u002E': return 0x0E;
|
||||
case '\u002F': return 0x0F;
|
||||
case '\u0030': return 0x10;
|
||||
case '\u0031': return 0x11;
|
||||
case '\u0032': return 0x12;
|
||||
case '\u0033': return 0x13;
|
||||
case '\u0034': return 0x14;
|
||||
case '\u0035': return 0x15;
|
||||
case '\u0036': return 0x16;
|
||||
case '\u0037': return 0x17;
|
||||
case '\u0038': return 0x18;
|
||||
case '\u0039': return 0x19;
|
||||
case '\u003A': return 0x1A;
|
||||
case '\u003B': return 0x1B;
|
||||
case '\u003C': return 0x1C;
|
||||
case '\u003D': return 0x1D;
|
||||
case '\u003E': return 0x1E;
|
||||
case '\u003F': return 0x1F;
|
||||
case '\u0040': return 0x20;
|
||||
case '\u0061': return 0x21;
|
||||
case '\u0062': return 0x22;
|
||||
case '\u0063': return 0x23;
|
||||
case '\u0064': return 0x24;
|
||||
case '\u0065': return 0x25;
|
||||
case '\u0066': return 0x26;
|
||||
case '\u0067': return 0x27;
|
||||
case '\u0068': return 0x28;
|
||||
case '\u0069': return 0x29;
|
||||
case '\u006A': return 0x2A;
|
||||
case '\u006B': return 0x2B;
|
||||
case '\u006C': return 0x2C;
|
||||
case '\u006D': return 0x2D;
|
||||
case '\u006E': return 0x2E;
|
||||
case '\u006F': return 0x2F;
|
||||
case '\u0070': return 0x30;
|
||||
case '\u0071': return 0x31;
|
||||
case '\u0072': return 0x32;
|
||||
case '\u0073': return 0x33;
|
||||
case '\u0074': return 0x34;
|
||||
case '\u0075': return 0x35;
|
||||
case '\u0076': return 0x36;
|
||||
case '\u0077': return 0x37;
|
||||
case '\u0078': return 0x38;
|
||||
case '\u0079': return 0x39;
|
||||
case '\u007A': return 0x3A;
|
||||
case '\u005B': return 0x3B;
|
||||
case '\u005C': return 0x3C;
|
||||
case '\u005D': return 0x3D;
|
||||
case '\u005E': return 0x3E;
|
||||
case '\u005F': return 0x3F;
|
||||
case '\u00A0': return 0x40;
|
||||
case '\u2575': return 0x41;
|
||||
case '\u2574': return 0x42;
|
||||
case '\u2577': return 0x43;
|
||||
case '\u2576': return 0x44;
|
||||
case '\u2518': return 0x45;
|
||||
case '\u2510': return 0x46;
|
||||
case '\u250C': return 0x47;
|
||||
case '\u2514': return 0x48;
|
||||
case '\u2500': return 0x49;
|
||||
case '\u2502': return 0x4A;
|
||||
case '\u2534': return 0x4B;
|
||||
case '\u2524': return 0x4C;
|
||||
case '\u252C': return 0x4D;
|
||||
case '\u251C': return 0x4E;
|
||||
case '\u253C': return 0x4F;
|
||||
case '\u25E4': return 0x50;
|
||||
case '\u25E5': return 0x51;
|
||||
case '\u2592': return 0x52;
|
||||
case '\u2598': return 0x53;
|
||||
case '\u259D': return 0x54;
|
||||
case '\u2580': return 0x55;
|
||||
case '\u2596': return 0x56;
|
||||
case '\u2597': return 0x57;
|
||||
case '\u259A': return 0x58;
|
||||
case '\u258C': return 0x59;
|
||||
case '\u2190': return 0x5C;
|
||||
case '\u2191': return 0x5D;
|
||||
case '\u2192': return 0x5E;
|
||||
case '\u2193': return 0x5F;
|
||||
case '\u03C0': return 0x60;
|
||||
case '\u0041': return 0x61;
|
||||
case '\u0042': return 0x62;
|
||||
case '\u0043': return 0x63;
|
||||
case '\u0044': return 0x64;
|
||||
case '\u0045': return 0x65;
|
||||
case '\u0046': return 0x66;
|
||||
case '\u0047': return 0x67;
|
||||
case '\u0048': return 0x68;
|
||||
case '\u0049': return 0x69;
|
||||
case '\u004A': return 0x6A;
|
||||
case '\u004B': return 0x6B;
|
||||
case '\u004C': return 0x6C;
|
||||
case '\u004D': return 0x6D;
|
||||
case '\u004E': return 0x6E;
|
||||
case '\u004F': return 0x6F;
|
||||
case '\u0050': return 0x70;
|
||||
case '\u0051': return 0x71;
|
||||
case '\u0052': return 0x72;
|
||||
case '\u0053': return 0x73;
|
||||
case '\u0054': return 0x74;
|
||||
case '\u0055': return 0x75;
|
||||
case '\u0056': return 0x76;
|
||||
case '\u0057': return 0x77;
|
||||
case '\u0058': return 0x78;
|
||||
case '\u0059': return 0x79;
|
||||
case '\u005A': return 0x7A;
|
||||
case '\u007B': return 0x7B;
|
||||
case '\u007C': return 0x7C;
|
||||
case '\u007D': return 0x7D;
|
||||
case '\u007E': return 0x7E;
|
||||
default:
|
||||
// Fallback to '?'
|
||||
return 0x3F;
|
||||
}
|
||||
}
|
||||
'\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
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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,561 +24,304 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Claunia.Encoding
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an Apple IIgs character encoding of Unicode characters.
|
||||
/// </summary>
|
||||
public class Apple2gs : Encoding
|
||||
/// <summary>Represents an Apple IIgs character encoding of Unicode characters.</summary>
|
||||
public class Apple2Gs : SingleByteEncodingWithRunes
|
||||
{
|
||||
const string _bodyname = "apple2gs";
|
||||
const int _codepage = 0;
|
||||
const string _encodingname = "Western European (Apple IIgs)";
|
||||
const string _headername = "apple2gs";
|
||||
const string _webname = "";
|
||||
const int _windowsCodepage = 0;
|
||||
/// <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;
|
||||
|
||||
const bool browserDisplay = false;
|
||||
const bool browserSave = false;
|
||||
const bool mailNewsDisplay = false;
|
||||
const bool mailNewsSave = false;
|
||||
const bool readOnly = true;
|
||||
const bool singleByte = true;
|
||||
/// <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>
|
||||
static readonly char[] Apple2gsTable =
|
||||
/// <summary>The Apple IIgs to Unicode character map. Inverted screen characters are mapped to normal characters.</summary>
|
||||
protected override Rune[] CharTable => new[]
|
||||
{
|
||||
// 0x00
|
||||
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
|
||||
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
|
||||
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
|
||||
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
|
||||
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
|
||||
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
|
||||
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u0020',
|
||||
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
|
||||
'\u2588', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
|
||||
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
|
||||
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u231B', '\u2713', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u2190', '\u2026', '\u2193', '\u2191', '\u0000', '\u21B5', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u2192', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u25C6', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
|
||||
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
|
||||
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
|
||||
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
|
||||
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
|
||||
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
|
||||
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u0000',
|
||||
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
|
||||
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
|
||||
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
|
||||
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
|
||||
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
|
||||
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
|
||||
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
|
||||
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
|
||||
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
|
||||
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
|
||||
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
|
||||
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
|
||||
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
|
||||
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
|
||||
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
|
||||
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
|
||||
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
|
||||
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
|
||||
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
|
||||
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
|
||||
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
|
||||
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
|
||||
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
|
||||
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
|
||||
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
|
||||
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
|
||||
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
|
||||
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
|
||||
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
|
||||
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
|
||||
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
|
||||
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u0000'
|
||||
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>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserDisplay => browserDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserSave => browserSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsDisplay => mailNewsDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsSave => mailNewsSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding is read-only.
|
||||
/// </summary>
|
||||
/// <value>The is single byte.</value>
|
||||
public override bool IsReadOnly => readOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding uses single-byte code points.
|
||||
/// </summary>
|
||||
public override bool IsSingleByte => singleByte;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the code page identifier of the current Encoding.
|
||||
/// </summary>
|
||||
public override int CodePage => _codepage;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent body tags
|
||||
/// </summary>
|
||||
public override string BodyName => _bodyname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent header tags
|
||||
/// </summary>
|
||||
public override string HeaderName => _headername;
|
||||
|
||||
/// <summary>
|
||||
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
|
||||
/// </summary>
|
||||
public override string WebName => _webname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the human-readable description of the current encoding.
|
||||
/// </summary>
|
||||
public override string EncodingName => _encodingname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
|
||||
/// </summary>
|
||||
public override int WindowsCodePage => _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) =>
|
||||
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 string(GetChars(bytes, index, count));
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Apple IIgs character to an Unicode character
|
||||
/// </summary>
|
||||
/// <returns>Unicode character.</returns>
|
||||
/// <param name="character">Apple IIgs character.</param>
|
||||
static char GetChar(byte character) => Apple2gsTable[character];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Unicode character to an Apple IIgs character
|
||||
/// </summary>
|
||||
/// <summary>Converts a Unicode character to an Apple IIgs character</summary>
|
||||
/// <returns>Apple IIgs character.</returns>
|
||||
/// <param name="character">Unicode character.</param>
|
||||
static byte GetByte(char character)
|
||||
private protected override byte GetByte(Rune character) => character.Value switch
|
||||
{
|
||||
switch(character)
|
||||
{
|
||||
case '\u2588': return 0x20;
|
||||
case '\u231B': return 0x43;
|
||||
case '\u2713': return 0x44;
|
||||
case '\u2190': return 0x48;
|
||||
case '\u2026': return 0x49;
|
||||
case '\u2193': return 0x4A;
|
||||
case '\u2191': return 0x4B;
|
||||
case '\u21B5': return 0x4D;
|
||||
case '\u2192': return 0x55;
|
||||
case '\u25C6': return 0x5B;
|
||||
case '\u0040': return 0x80;
|
||||
case '\u0041': return 0x81;
|
||||
case '\u0042': return 0x82;
|
||||
case '\u0043': return 0x83;
|
||||
case '\u0044': return 0x84;
|
||||
case '\u0045': return 0x85;
|
||||
case '\u0046': return 0x86;
|
||||
case '\u0047': return 0x87;
|
||||
case '\u0048': return 0x88;
|
||||
case '\u0049': return 0x89;
|
||||
case '\u004A': return 0x8A;
|
||||
case '\u004B': return 0x8B;
|
||||
case '\u004C': return 0x8C;
|
||||
case '\u004D': return 0x8D;
|
||||
case '\u004E': return 0x8E;
|
||||
case '\u004F': return 0x8F;
|
||||
case '\u0050': return 0x90;
|
||||
case '\u0051': return 0x91;
|
||||
case '\u0052': return 0x92;
|
||||
case '\u0053': return 0x93;
|
||||
case '\u0054': return 0x94;
|
||||
case '\u0055': return 0x95;
|
||||
case '\u0056': return 0x96;
|
||||
case '\u0057': return 0x97;
|
||||
case '\u0058': return 0x98;
|
||||
case '\u0059': return 0x99;
|
||||
case '\u005A': return 0x9A;
|
||||
case '\u005B': return 0x9B;
|
||||
case '\u005C': return 0x9C;
|
||||
case '\u005D': return 0x9D;
|
||||
case '\u005E': return 0x9E;
|
||||
case '\u005F': return 0x9F;
|
||||
case '\u0020': return 0xA0;
|
||||
case '\u0021': return 0xA1;
|
||||
case '\u0022': return 0xA2;
|
||||
case '\u0023': return 0xA3;
|
||||
case '\u0024': return 0xA4;
|
||||
case '\u2025': return 0xA5;
|
||||
case '\u0026': return 0xA6;
|
||||
case '\u0027': return 0xA7;
|
||||
case '\u0028': return 0xA8;
|
||||
case '\u0029': return 0xA9;
|
||||
case '\u002A': return 0xAA;
|
||||
case '\u002B': return 0xAB;
|
||||
case '\u002C': return 0xAC;
|
||||
case '\u002D': return 0xAD;
|
||||
case '\u002E': return 0xAE;
|
||||
case '\u002F': return 0xAF;
|
||||
case '\u0030': return 0xB0;
|
||||
case '\u0031': return 0xB1;
|
||||
case '\u0032': return 0xB2;
|
||||
case '\u0033': return 0xB3;
|
||||
case '\u0034': return 0xB4;
|
||||
case '\u0035': return 0xB5;
|
||||
case '\u0036': return 0xB6;
|
||||
case '\u0037': return 0xB7;
|
||||
case '\u0038': return 0xB8;
|
||||
case '\u0039': return 0xB9;
|
||||
case '\u003A': return 0xBA;
|
||||
case '\u003B': return 0xBB;
|
||||
case '\u003C': return 0xBC;
|
||||
case '\u003D': return 0xBD;
|
||||
case '\u003E': return 0xBE;
|
||||
case '\u003F': return 0xBF;
|
||||
case '\u0060': return 0xE0;
|
||||
case '\u0061': return 0xE1;
|
||||
case '\u0062': return 0xE2;
|
||||
case '\u0063': return 0xE3;
|
||||
case '\u0064': return 0xE4;
|
||||
case '\u0065': return 0xE5;
|
||||
case '\u0066': return 0xE6;
|
||||
case '\u0067': return 0xE7;
|
||||
case '\u0068': return 0xE8;
|
||||
case '\u0069': return 0xE9;
|
||||
case '\u006A': return 0xEA;
|
||||
case '\u006B': return 0xEB;
|
||||
case '\u006C': return 0xEC;
|
||||
case '\u006D': return 0xED;
|
||||
case '\u006E': return 0xEE;
|
||||
case '\u006F': return 0xEF;
|
||||
case '\u0070': return 0xF0;
|
||||
case '\u0071': return 0xF1;
|
||||
case '\u0072': return 0xF2;
|
||||
case '\u0073': return 0xF3;
|
||||
case '\u0074': return 0xF4;
|
||||
case '\u0075': return 0xF5;
|
||||
case '\u0076': return 0xF6;
|
||||
case '\u0077': return 0xF7;
|
||||
case '\u0078': return 0xF8;
|
||||
case '\u0079': return 0xF9;
|
||||
case '\u007A': return 0xFA;
|
||||
case '\u007B': return 0xFB;
|
||||
case '\u007C': return 0xFC;
|
||||
case '\u007D': return 0xFD;
|
||||
case '\u007E': return 0xFE;
|
||||
default:
|
||||
// Fallback to '?'
|
||||
return 0xBF;
|
||||
}
|
||||
}
|
||||
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
@@ -1,59 +1,58 @@
|
||||
<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.7</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>
|
||||
<PackageLicenseUrl>https://raw.githubusercontent.com/claunia/Claunia.Encoding/master/LICENSE.MIT</PackageLicenseUrl>
|
||||
<ReleaseVersion>1.7</ReleaseVersion>
|
||||
<PackageReleaseNotes>Support .NET Core and .NET Framework 4.0.</PackageReleaseNotes>
|
||||
<TargetFrameworks>net40;netstandard2.0</TargetFrameworks>
|
||||
<VersionPrefix>1.7</VersionPrefix>
|
||||
<Company>Claunia.com</Company>
|
||||
<Copyright>© 2016-2019 Natalia Portillo</Copyright>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<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>
|
||||
</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 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</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</ReleaseVersion>
|
||||
<PackageReleaseNotes>Updated all codepages to include symbols defined as of Unicode 13.0</PackageReleaseNotes>
|
||||
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
|
||||
<VersionPrefix>1.9</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>
|
||||
</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>
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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
|
||||
@@ -31,115 +31,75 @@ using System.Reflection;
|
||||
|
||||
namespace Claunia.Encoding
|
||||
{
|
||||
/// <summary>
|
||||
/// This class contains static instances of the supported encodings.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <summary>Static instance for the GEM encoding</summary>
|
||||
public static System.Text.Encoding GemEncoding = new Gem();
|
||||
/// <summary>
|
||||
/// Static instance for the GEM encoding
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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.
|
||||
/// 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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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))
|
||||
let encoding = (Encoding)type.GetConstructor(new Type[] { }).Invoke(new object[] { })
|
||||
select new EncodingInfo(encoding.CodePage, encoding.BodyName, encoding.EncodingName, false, type))
|
||||
.ToArray();
|
||||
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>
|
||||
/// <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.
|
||||
@@ -148,10 +108,15 @@ namespace Claunia.Encoding
|
||||
public new static System.Text.Encoding GetEncoding(string name)
|
||||
{
|
||||
foreach(Type type in Assembly.GetExecutingAssembly().GetTypes())
|
||||
if(type.IsSubclassOf(typeof(Encoding)))
|
||||
if(type.IsSubclassOf(typeof(Encoding)) &&
|
||||
!type.IsAbstract)
|
||||
{
|
||||
Encoding encoding = (Encoding)type.GetConstructor(new Type[] { }).Invoke(new object[] { });
|
||||
if(encoding.BodyName == name.ToLowerInvariant()) return encoding;
|
||||
var encoding = (Encoding)type.GetConstructor(new Type[]
|
||||
{})?.Invoke(new object[]
|
||||
{});
|
||||
|
||||
if(encoding?.BodyName == name.ToLowerInvariant())
|
||||
return encoding;
|
||||
}
|
||||
|
||||
return System.Text.Encoding.GetEncoding(name);
|
||||
|
||||
@@ -6,54 +6,44 @@ using System;
|
||||
|
||||
namespace Claunia.Encoding
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides basic information about an encoding.
|
||||
/// </summary>
|
||||
/// <summary>Provides basic information about an encoding.</summary>
|
||||
public sealed class EncodingInfo
|
||||
{
|
||||
bool isSystem;
|
||||
readonly Type thisType;
|
||||
readonly Type _thisType;
|
||||
bool _isSystem;
|
||||
|
||||
internal EncodingInfo(int codePage, string name, string displayName, bool system = true,
|
||||
internal EncodingInfo(int codePage, string name, string displayName, bool system = true,
|
||||
Type internalType = null)
|
||||
{
|
||||
CodePage = codePage;
|
||||
Name = name;
|
||||
DisplayName = displayName;
|
||||
isSystem = system;
|
||||
thisType = internalType;
|
||||
_isSystem = system;
|
||||
_thisType = internalType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the code page identifier of the encoding.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <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[] { });
|
||||
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>
|
||||
/// <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
|
||||
@@ -61,9 +51,7 @@ namespace Claunia.Encoding
|
||||
/// </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>
|
||||
/// <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;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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,673 +24,360 @@
|
||||
// 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 Apple Lisa character encoding of Unicode characters.
|
||||
/// </summary>
|
||||
public class LisaRoman : Encoding
|
||||
/// <summary>Represents an Apple Lisa character encoding of Unicode characters.</summary>
|
||||
public class LisaRoman : SingleByteEncoding
|
||||
{
|
||||
const string _bodyname = "lisa";
|
||||
const int _codepage = 0;
|
||||
const string _encodingname = "Western European (Apple Lisa)";
|
||||
const string _headername = "lisa";
|
||||
const string _webname = "";
|
||||
const int _windowsCodepage = 10000;
|
||||
/// <inheritdoc />
|
||||
public override string BodyName => "lisa";
|
||||
/// <inheritdoc />
|
||||
public override int CodePage => 0;
|
||||
/// <inheritdoc />
|
||||
public override string EncodingName => "Western European (Apple Lisa)";
|
||||
/// <inheritdoc />
|
||||
public override string HeaderName => "lisa";
|
||||
/// <inheritdoc />
|
||||
public override string WebName => "";
|
||||
/// <inheritdoc />
|
||||
public override int WindowsCodePage => 10000;
|
||||
|
||||
const bool browserDisplay = false;
|
||||
const bool browserSave = false;
|
||||
const bool mailNewsDisplay = false;
|
||||
const bool mailNewsSave = false;
|
||||
const bool readOnly = false;
|
||||
const bool singleByte = true;
|
||||
/// <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 Lisa to Unicode character map.
|
||||
/// MacRoman is a superset of LisaRoman.
|
||||
/// </summary>
|
||||
static readonly char[] LisaRomanTable =
|
||||
/// <summary>The Lisa 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', '\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', '\u2588',
|
||||
|
||||
// 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', '\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>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserDisplay => browserDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserSave => browserSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsDisplay => mailNewsDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsSave => mailNewsSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding is read-only.
|
||||
/// </summary>
|
||||
/// <value>The is single byte.</value>
|
||||
public override bool IsReadOnly => readOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding uses single-byte code points.
|
||||
/// </summary>
|
||||
public override bool IsSingleByte => singleByte;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the code page identifier of the current Encoding.
|
||||
/// </summary>
|
||||
public override int CodePage => _codepage;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent body tags
|
||||
/// </summary>
|
||||
public override string BodyName => _bodyname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent header tags
|
||||
/// </summary>
|
||||
public override string HeaderName => _headername;
|
||||
|
||||
/// <summary>
|
||||
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
|
||||
/// </summary>
|
||||
public override string WebName => _webname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the human-readable description of the current encoding.
|
||||
/// </summary>
|
||||
public override string EncodingName => _encodingname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
|
||||
/// </summary>
|
||||
public override int WindowsCodePage => _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) =>
|
||||
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 string(GetChars(bytes, index, count));
|
||||
|
||||
/// <summary>
|
||||
/// Converts a LisaRoman character to an Unicode character
|
||||
/// </summary>
|
||||
/// <returns>Unicode character.</returns>
|
||||
/// <param name="character">LisaRoman character.</param>
|
||||
static char GetChar(byte character) => LisaRomanTable[character];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Unicode character to an LisaRoman character
|
||||
/// </summary>
|
||||
/// <summary>Converts a Unicode character to an LisaRoman character</summary>
|
||||
/// <returns>LisaRoman character.</returns>
|
||||
/// <param name="character">Unicode character.</param>
|
||||
static byte GetByte(char character)
|
||||
private protected override byte GetByte(char character) => character switch
|
||||
{
|
||||
switch(character)
|
||||
{
|
||||
case '\u0000': return 0x00;
|
||||
case '\u0001': return 0x01;
|
||||
case '\u0002': return 0x02;
|
||||
case '\u0003': return 0x03;
|
||||
case '\u0004': return 0x04;
|
||||
case '\u0005': return 0x05;
|
||||
case '\u0006': return 0x06;
|
||||
case '\u0007': return 0x07;
|
||||
case '\u0008': return 0x08;
|
||||
case '\u0009': return 0x09;
|
||||
case '\u000A': return 0x0A;
|
||||
case '\u000B': return 0x0B;
|
||||
case '\u000C': return 0x0C;
|
||||
case '\u000D': return 0x0D;
|
||||
case '\u000E': return 0x0E;
|
||||
case '\u000F': return 0x0F;
|
||||
case '\u0010': return 0x10;
|
||||
case '\u0011': return 0x11;
|
||||
case '\u0012': return 0x12;
|
||||
case '\u0013': return 0x13;
|
||||
case '\u0014': return 0x14;
|
||||
case '\u0015': return 0x15;
|
||||
case '\u0016': return 0x16;
|
||||
case '\u0017': return 0x17;
|
||||
case '\u0018': return 0x18;
|
||||
case '\u0019': return 0x19;
|
||||
case '\u001A': return 0x1A;
|
||||
case '\u001B': return 0x1B;
|
||||
case '\u001C': return 0x1C;
|
||||
case '\u001D': return 0x1D;
|
||||
case '\u001E': return 0x1E;
|
||||
case '\u001F': return 0x1F;
|
||||
case '\u0020': return 0x20;
|
||||
case '\u0021': return 0x21;
|
||||
case '\u0022': return 0x22;
|
||||
case '\u0023': return 0x23;
|
||||
case '\u0024': return 0x24;
|
||||
case '\u0025': return 0x25;
|
||||
case '\u0026': return 0x26;
|
||||
case '\u0027': return 0x27;
|
||||
case '\u0028': return 0x28;
|
||||
case '\u0029': return 0x29;
|
||||
case '\u002A': return 0x2A;
|
||||
case '\u002B': return 0x2B;
|
||||
case '\u002C': return 0x2C;
|
||||
case '\u002D': return 0x2D;
|
||||
case '\u002E': return 0x2E;
|
||||
case '\u002F': return 0x2F;
|
||||
case '\u0030': return 0x30;
|
||||
case '\u0031': return 0x31;
|
||||
case '\u0032': return 0x32;
|
||||
case '\u0033': return 0x33;
|
||||
case '\u0034': return 0x34;
|
||||
case '\u0035': return 0x35;
|
||||
case '\u0036': return 0x36;
|
||||
case '\u0037': return 0x37;
|
||||
case '\u0038': return 0x38;
|
||||
case '\u0039': return 0x39;
|
||||
case '\u003A': return 0x3A;
|
||||
case '\u003B': return 0x3B;
|
||||
case '\u003C': return 0x3C;
|
||||
case '\u003D': return 0x3D;
|
||||
case '\u003E': return 0x3E;
|
||||
case '\u003F': return 0x3F;
|
||||
case '\u0040': return 0x40;
|
||||
case '\u0041': return 0x41;
|
||||
case '\u0042': return 0x42;
|
||||
case '\u0043': return 0x43;
|
||||
case '\u0044': return 0x44;
|
||||
case '\u0045': return 0x45;
|
||||
case '\u0046': return 0x46;
|
||||
case '\u0047': return 0x47;
|
||||
case '\u0048': return 0x48;
|
||||
case '\u0049': return 0x49;
|
||||
case '\u004A': return 0x4A;
|
||||
case '\u004B': return 0x4B;
|
||||
case '\u004C': return 0x4C;
|
||||
case '\u004D': return 0x4D;
|
||||
case '\u004E': return 0x4E;
|
||||
case '\u004F': return 0x4F;
|
||||
case '\u0050': return 0x50;
|
||||
case '\u0051': return 0x51;
|
||||
case '\u0052': return 0x52;
|
||||
case '\u0053': return 0x53;
|
||||
case '\u0054': return 0x54;
|
||||
case '\u0055': return 0x55;
|
||||
case '\u0056': return 0x56;
|
||||
case '\u0057': return 0x57;
|
||||
case '\u0058': return 0x58;
|
||||
case '\u0059': return 0x59;
|
||||
case '\u005A': return 0x5A;
|
||||
case '\u005B': return 0x5B;
|
||||
case '\u005C': return 0x5C;
|
||||
case '\u005D': return 0x5D;
|
||||
case '\u005E': return 0x5E;
|
||||
case '\u005F': return 0x5F;
|
||||
case '\u0060': return 0x60;
|
||||
case '\u0061': return 0x61;
|
||||
case '\u0062': return 0x62;
|
||||
case '\u0063': return 0x63;
|
||||
case '\u0064': return 0x64;
|
||||
case '\u0065': return 0x65;
|
||||
case '\u0066': return 0x66;
|
||||
case '\u0067': return 0x67;
|
||||
case '\u0068': return 0x68;
|
||||
case '\u0069': return 0x69;
|
||||
case '\u006A': return 0x6A;
|
||||
case '\u006B': return 0x6B;
|
||||
case '\u006C': return 0x6C;
|
||||
case '\u006D': return 0x6D;
|
||||
case '\u006E': return 0x6E;
|
||||
case '\u006F': return 0x6F;
|
||||
case '\u0070': return 0x70;
|
||||
case '\u0071': return 0x71;
|
||||
case '\u0072': return 0x72;
|
||||
case '\u0073': return 0x73;
|
||||
case '\u0074': return 0x74;
|
||||
case '\u0075': return 0x75;
|
||||
case '\u0076': return 0x76;
|
||||
case '\u0077': return 0x77;
|
||||
case '\u0078': return 0x78;
|
||||
case '\u0079': return 0x79;
|
||||
case '\u007A': return 0x7A;
|
||||
case '\u007B': return 0x7B;
|
||||
case '\u007C': return 0x7C;
|
||||
case '\u007D': return 0x7D;
|
||||
case '\u007E': return 0x7E;
|
||||
case '\u2588': return 0x7F;
|
||||
case '\u00C4': return 0x80;
|
||||
case '\u00C5': return 0x81;
|
||||
case '\u00C7': return 0x82;
|
||||
case '\u00C9': return 0x83;
|
||||
case '\u00D1': return 0x84;
|
||||
case '\u00D6': return 0x85;
|
||||
case '\u00DC': return 0x86;
|
||||
case '\u00E1': return 0x87;
|
||||
case '\u00E0': return 0x88;
|
||||
case '\u00E2': return 0x89;
|
||||
case '\u00E4': return 0x8A;
|
||||
case '\u00E3': return 0x8B;
|
||||
case '\u00E5': return 0x8C;
|
||||
case '\u00E7': return 0x8D;
|
||||
case '\u00E9': return 0x8E;
|
||||
case '\u00E8': return 0x8F;
|
||||
case '\u00EA': return 0x90;
|
||||
case '\u00EB': return 0x91;
|
||||
case '\u00ED': return 0x92;
|
||||
case '\u00EC': return 0x93;
|
||||
case '\u00EE': return 0x94;
|
||||
case '\u00EF': return 0x95;
|
||||
case '\u00F1': return 0x96;
|
||||
case '\u00F3': return 0x97;
|
||||
case '\u00F2': return 0x98;
|
||||
case '\u00F4': return 0x99;
|
||||
case '\u00F6': return 0x9A;
|
||||
case '\u00F5': return 0x9B;
|
||||
case '\u00FA': return 0x9C;
|
||||
case '\u00F9': return 0x9D;
|
||||
case '\u00FB': return 0x9E;
|
||||
case '\u00FC': return 0x9F;
|
||||
case '\u2020': return 0xA0;
|
||||
case '\u00B0': return 0xA1;
|
||||
case '\u00A2': return 0xA2;
|
||||
case '\u00A3': return 0xA3;
|
||||
case '\u00A7': return 0xA4;
|
||||
case '\u2022': return 0xA5;
|
||||
case '\u00B6': return 0xA6;
|
||||
case '\u00DF': return 0xA7;
|
||||
case '\u00AE': return 0xA8;
|
||||
case '\u00A9': return 0xA9;
|
||||
case '\u2122': return 0xAA;
|
||||
case '\u00B4': return 0xAB;
|
||||
case '\u00A8': return 0xAC;
|
||||
case '\u2260': return 0xAD;
|
||||
case '\u00C6': return 0xAE;
|
||||
case '\u00D8': return 0xAF;
|
||||
case '\u221E': return 0xB0;
|
||||
case '\u00B1': return 0xB1;
|
||||
case '\u2264': return 0xB2;
|
||||
case '\u2265': return 0xB3;
|
||||
case '\u00A5': return 0xB4;
|
||||
case '\u00B5': return 0xB5;
|
||||
case '\u2202': return 0xB6;
|
||||
case '\u2211': return 0xB7;
|
||||
case '\u220F': return 0xB8;
|
||||
case '\u03C0': return 0xB9;
|
||||
case '\u222B': return 0xBA;
|
||||
case '\u00AA': return 0xBB;
|
||||
case '\u00BA': return 0xBC;
|
||||
case '\u03A9': return 0xBD;
|
||||
case '\u00E6': return 0xBE;
|
||||
case '\u00F8': return 0xBF;
|
||||
case '\u00BF': return 0xC0;
|
||||
case '\u00A1': return 0xC1;
|
||||
case '\u00AC': return 0xC2;
|
||||
case '\u221A': return 0xC3;
|
||||
case '\u0192': return 0xC4;
|
||||
case '\u2248': return 0xC5;
|
||||
case '\u2206': return 0xC6;
|
||||
case '\u00AB': return 0xC7;
|
||||
case '\u00BB': return 0xC8;
|
||||
case '\u2026': return 0xC9;
|
||||
case '\u00A0': return 0xCA;
|
||||
case '\u00C0': return 0xCB;
|
||||
case '\u00C3': return 0xCC;
|
||||
case '\u00D5': return 0xCD;
|
||||
case '\u0152': return 0xCE;
|
||||
case '\u0153': return 0xCF;
|
||||
case '\u2013': return 0xD0;
|
||||
case '\u2014': return 0xD1;
|
||||
case '\u201C': return 0xD2;
|
||||
case '\u201D': return 0xD3;
|
||||
case '\u2018': return 0xD4;
|
||||
case '\u2019': return 0xD5;
|
||||
case '\u00F7': return 0xD6;
|
||||
case '\u25CA': return 0xD7;
|
||||
case '\u00FF': return 0xD8;
|
||||
default:
|
||||
// Fallback to '?'
|
||||
return 0x3F;
|
||||
}
|
||||
}
|
||||
'\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,
|
||||
'\u2588' => 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,
|
||||
_ => 0x3F
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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,685 +24,376 @@
|
||||
// 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 Mac Arabic character encoding of Unicode characters.
|
||||
/// </summary>
|
||||
public class MacArabic : Encoding
|
||||
/// <summary>Represents an Mac Arabic character encoding of Unicode characters.</summary>
|
||||
public class MacArabic : SingleByteEncoding
|
||||
{
|
||||
const string _bodyname = "x-mac-arabic";
|
||||
const int _codepage = 10004;
|
||||
const string _encodingname = "Arabic (Mac)";
|
||||
const string _headername = "x-mac-arabic";
|
||||
const string _webname = "x-mac-arabic";
|
||||
const int _windowsCodepage = 10004;
|
||||
/// <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;
|
||||
|
||||
const bool browserDisplay = false;
|
||||
const bool browserSave = false;
|
||||
const bool mailNewsDisplay = false;
|
||||
const bool mailNewsSave = false;
|
||||
const bool readOnly = true;
|
||||
const bool singleByte = true;
|
||||
/// <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>
|
||||
static readonly char[] MacArabicTable =
|
||||
/// <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', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
|
||||
'\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>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserDisplay => browserDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserSave => browserSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsDisplay => mailNewsDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsSave => mailNewsSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding is read-only.
|
||||
/// </summary>
|
||||
/// <value>The is single byte.</value>
|
||||
public override bool IsReadOnly => readOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding uses single-byte code points.
|
||||
/// </summary>
|
||||
public override bool IsSingleByte => singleByte;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the code page identifier of the current Encoding.
|
||||
/// </summary>
|
||||
public override int CodePage => _codepage;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent body tags
|
||||
/// </summary>
|
||||
public override string BodyName => _bodyname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent header tags
|
||||
/// </summary>
|
||||
public override string HeaderName => _headername;
|
||||
|
||||
/// <summary>
|
||||
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
|
||||
/// </summary>
|
||||
public override string WebName => _webname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the human-readable description of the current encoding.
|
||||
/// </summary>
|
||||
public override string EncodingName => _encodingname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
|
||||
/// </summary>
|
||||
public override int WindowsCodePage => _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) =>
|
||||
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 string(GetChars(bytes, index, count));
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Mac Arabic character to an Unicode character
|
||||
/// </summary>
|
||||
/// <returns>Unicode character.</returns>
|
||||
/// <param name="character">Mac Arabic character.</param>
|
||||
static char GetChar(byte character) => MacArabicTable[character];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Unicode character to an Mac Arabic character
|
||||
/// </summary>
|
||||
/// <summary>Converts a Unicode character to an Mac Arabic character</summary>
|
||||
/// <returns>Mac Arabic character.</returns>
|
||||
/// <param name="character">Unicode character.</param>
|
||||
static byte GetByte(char character)
|
||||
private protected override byte GetByte(char character) => character switch
|
||||
{
|
||||
switch(character)
|
||||
{
|
||||
case '\u0000': return 0x00;
|
||||
case '\u0001': return 0x01;
|
||||
case '\u0002': return 0x02;
|
||||
case '\u0003': return 0x03;
|
||||
case '\u0004': return 0x04;
|
||||
case '\u0005': return 0x05;
|
||||
case '\u0006': return 0x06;
|
||||
case '\u0007': return 0x07;
|
||||
case '\u0008': return 0x08;
|
||||
case '\u0009': return 0x09;
|
||||
case '\u000A': return 0x0A;
|
||||
case '\u000B': return 0x0B;
|
||||
case '\u000C': return 0x0C;
|
||||
case '\u000D': return 0x0D;
|
||||
case '\u000E': return 0x0E;
|
||||
case '\u000F': return 0x0F;
|
||||
case '\u0010': return 0x10;
|
||||
case '\u0011': return 0x11;
|
||||
case '\u0012': return 0x12;
|
||||
case '\u0013': return 0x13;
|
||||
case '\u0014': return 0x14;
|
||||
case '\u0015': return 0x15;
|
||||
case '\u0016': return 0x16;
|
||||
case '\u0017': return 0x17;
|
||||
case '\u0018': return 0x18;
|
||||
case '\u0019': return 0x19;
|
||||
case '\u001A': return 0x1A;
|
||||
case '\u001B': return 0x1B;
|
||||
case '\u001C': return 0x1C;
|
||||
case '\u001D': return 0x1D;
|
||||
case '\u001E': return 0x1E;
|
||||
case '\u001F': return 0x1F;
|
||||
case '\u0020': return 0x20;
|
||||
case '\u0021': return 0x21;
|
||||
case '\u0022': return 0x22;
|
||||
case '\u0023': return 0x23;
|
||||
case '\u0024': return 0x24;
|
||||
case '\u0025': return 0x25;
|
||||
case '\u0026': return 0x26;
|
||||
case '\u0027': return 0x27;
|
||||
case '\u0028': return 0x28;
|
||||
case '\u0029': return 0x29;
|
||||
case '\u002A': return 0x2A;
|
||||
case '\u002B': return 0x2B;
|
||||
case '\u002C': return 0x2C;
|
||||
case '\u002D': return 0x2D;
|
||||
case '\u002E': return 0x2E;
|
||||
case '\u002F': return 0x2F;
|
||||
case '\u0030': return 0x30;
|
||||
case '\u0031': return 0x31;
|
||||
case '\u0032': return 0x32;
|
||||
case '\u0033': return 0x33;
|
||||
case '\u0034': return 0x34;
|
||||
case '\u0035': return 0x35;
|
||||
case '\u0036': return 0x36;
|
||||
case '\u0037': return 0x37;
|
||||
case '\u0038': return 0x38;
|
||||
case '\u0039': return 0x39;
|
||||
case '\u003A': return 0x3A;
|
||||
case '\u003B': return 0x3B;
|
||||
case '\u003C': return 0x3C;
|
||||
case '\u003D': return 0x3D;
|
||||
case '\u003E': return 0x3E;
|
||||
case '\u003F': return 0x3F;
|
||||
case '\u0040': return 0x40;
|
||||
case '\u0041': return 0x41;
|
||||
case '\u0042': return 0x42;
|
||||
case '\u0043': return 0x43;
|
||||
case '\u0044': return 0x44;
|
||||
case '\u0045': return 0x45;
|
||||
case '\u0046': return 0x46;
|
||||
case '\u0047': return 0x47;
|
||||
case '\u0048': return 0x48;
|
||||
case '\u0049': return 0x49;
|
||||
case '\u004A': return 0x4A;
|
||||
case '\u004B': return 0x4B;
|
||||
case '\u004C': return 0x4C;
|
||||
case '\u004D': return 0x4D;
|
||||
case '\u004E': return 0x4E;
|
||||
case '\u004F': return 0x4F;
|
||||
case '\u0050': return 0x50;
|
||||
case '\u0051': return 0x51;
|
||||
case '\u0052': return 0x52;
|
||||
case '\u0053': return 0x53;
|
||||
case '\u0054': return 0x54;
|
||||
case '\u0055': return 0x55;
|
||||
case '\u0056': return 0x56;
|
||||
case '\u0057': return 0x57;
|
||||
case '\u0058': return 0x58;
|
||||
case '\u0059': return 0x59;
|
||||
case '\u005A': return 0x5A;
|
||||
case '\u005B': return 0x5B;
|
||||
case '\u005C': return 0x5C;
|
||||
case '\u005D': return 0x5D;
|
||||
case '\u005E': return 0x5E;
|
||||
case '\u005F': return 0x5F;
|
||||
case '\u0060': return 0x60;
|
||||
case '\u0061': return 0x61;
|
||||
case '\u0062': return 0x62;
|
||||
case '\u0063': return 0x63;
|
||||
case '\u0064': return 0x64;
|
||||
case '\u0065': return 0x65;
|
||||
case '\u0066': return 0x66;
|
||||
case '\u0067': return 0x67;
|
||||
case '\u0068': return 0x68;
|
||||
case '\u0069': return 0x69;
|
||||
case '\u006A': return 0x6A;
|
||||
case '\u006B': return 0x6B;
|
||||
case '\u006C': return 0x6C;
|
||||
case '\u006D': return 0x6D;
|
||||
case '\u006E': return 0x6E;
|
||||
case '\u006F': return 0x6F;
|
||||
case '\u0070': return 0x70;
|
||||
case '\u0071': return 0x71;
|
||||
case '\u0072': return 0x72;
|
||||
case '\u0073': return 0x73;
|
||||
case '\u0074': return 0x74;
|
||||
case '\u0075': return 0x75;
|
||||
case '\u0076': return 0x76;
|
||||
case '\u0077': return 0x77;
|
||||
case '\u0078': return 0x78;
|
||||
case '\u0079': return 0x79;
|
||||
case '\u007A': return 0x7A;
|
||||
case '\u007B': return 0x7B;
|
||||
case '\u007C': return 0x7C;
|
||||
case '\u007D': return 0x7D;
|
||||
case '\u007E': return 0x7E;
|
||||
case '\u007F': return 0x7F;
|
||||
case '\u00C4': return 0x80;
|
||||
case '\u00A0': return 0x81;
|
||||
case '\u00C7': return 0x82;
|
||||
case '\u00C9': return 0x83;
|
||||
case '\u00D1': return 0x84;
|
||||
case '\u00D6': return 0x85;
|
||||
case '\u00DC': return 0x86;
|
||||
case '\u00E1': return 0x87;
|
||||
case '\u00E0': return 0x88;
|
||||
case '\u00E2': return 0x89;
|
||||
case '\u00E4': return 0x8A;
|
||||
case '\u06BA': return 0x8B;
|
||||
case '\u00AB': return 0x8C;
|
||||
case '\u00E7': return 0x8D;
|
||||
case '\u00E9': return 0x8E;
|
||||
case '\u00E8': return 0x8F;
|
||||
case '\u00EA': return 0x90;
|
||||
case '\u00EB': return 0x91;
|
||||
case '\u00ED': return 0x92;
|
||||
case '\u2026': return 0x93;
|
||||
case '\u00EE': return 0x94;
|
||||
case '\u00EF': return 0x95;
|
||||
case '\u00F1': return 0x96;
|
||||
case '\u00F3': return 0x97;
|
||||
case '\u00BB': return 0x98;
|
||||
case '\u00F4': return 0x99;
|
||||
case '\u00F6': return 0x9A;
|
||||
case '\u00F7': return 0x9B;
|
||||
case '\u00FA': return 0x9C;
|
||||
case '\u00F9': return 0x9D;
|
||||
case '\u00FB': return 0x9E;
|
||||
case '\u00FC': return 0x9F;
|
||||
case '\u066A': return 0xA5;
|
||||
case '\u060C': return 0xAC;
|
||||
case '\u0660': return 0xB0;
|
||||
case '\u0661': return 0xB1;
|
||||
case '\u0662': return 0xB2;
|
||||
case '\u0663': return 0xB3;
|
||||
case '\u0664': return 0xB4;
|
||||
case '\u0665': return 0xB5;
|
||||
case '\u0666': return 0xB6;
|
||||
case '\u0667': return 0xB7;
|
||||
case '\u0668': return 0xB8;
|
||||
case '\u0669': return 0xB9;
|
||||
case '\u061B': return 0xBB;
|
||||
case '\u061F': return 0xBF;
|
||||
case '\u274A': return 0xC0;
|
||||
case '\u0621': return 0xC1;
|
||||
case '\u0622': return 0xC2;
|
||||
case '\u0623': return 0xC3;
|
||||
case '\u0624': return 0xC4;
|
||||
case '\u0625': return 0xC5;
|
||||
case '\u0626': return 0xC6;
|
||||
case '\u0627': return 0xC7;
|
||||
case '\u0628': return 0xC8;
|
||||
case '\u0629': return 0xC9;
|
||||
case '\u062A': return 0xCA;
|
||||
case '\u062B': return 0xCB;
|
||||
case '\u062C': return 0xCC;
|
||||
case '\u062D': return 0xCD;
|
||||
case '\u062E': return 0xCE;
|
||||
case '\u062F': return 0xCF;
|
||||
case '\u0630': return 0xD0;
|
||||
case '\u0631': return 0xD1;
|
||||
case '\u0632': return 0xD2;
|
||||
case '\u0633': return 0xD3;
|
||||
case '\u0634': return 0xD4;
|
||||
case '\u0635': return 0xD5;
|
||||
case '\u0636': return 0xD6;
|
||||
case '\u0637': return 0xD7;
|
||||
case '\u0638': return 0xD8;
|
||||
case '\u0639': return 0xD9;
|
||||
case '\u063A': return 0xDA;
|
||||
case '\u0640': return 0xE0;
|
||||
case '\u0641': return 0xE1;
|
||||
case '\u0642': return 0xE2;
|
||||
case '\u0643': return 0xE3;
|
||||
case '\u0644': return 0xE4;
|
||||
case '\u0645': return 0xE5;
|
||||
case '\u0646': return 0xE6;
|
||||
case '\u0647': return 0xE7;
|
||||
case '\u0648': return 0xE8;
|
||||
case '\u0649': return 0xE9;
|
||||
case '\u064A': return 0xEA;
|
||||
case '\u064B': return 0xEB;
|
||||
case '\u064C': return 0xEC;
|
||||
case '\u064D': return 0xED;
|
||||
case '\u064E': return 0xEE;
|
||||
case '\u064F': return 0xEF;
|
||||
case '\u0650': return 0xF0;
|
||||
case '\u0651': return 0xF1;
|
||||
case '\u0652': return 0xF2;
|
||||
case '\u067E': return 0xF3;
|
||||
case '\u0679': return 0xF4;
|
||||
case '\u0686': return 0xF5;
|
||||
case '\u06D5': return 0xF6;
|
||||
case '\u06A4': return 0xF7;
|
||||
case '\u06AF': return 0xF8;
|
||||
case '\u0688': return 0xF9;
|
||||
case '\u0691': return 0xFA;
|
||||
case '\u0698': return 0xFE;
|
||||
case '\u06D2': return 0xFF;
|
||||
default:
|
||||
// Fallback to '?'
|
||||
return 0x3F;
|
||||
}
|
||||
}
|
||||
'\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
|
||||
};
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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,685 +24,376 @@
|
||||
// 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 Mac Farsi character encoding of Unicode characters.
|
||||
/// </summary>
|
||||
public class MacFarsi : Encoding
|
||||
/// <summary>Represents an Mac Farsi character encoding of Unicode characters.</summary>
|
||||
public class MacFarsi : SingleByteEncoding
|
||||
{
|
||||
const string _bodyname = "x-mac-farsi";
|
||||
const int _codepage = 10014;
|
||||
const string _encodingname = "Farsi (Mac)";
|
||||
const string _headername = "x-mac-farsi";
|
||||
const string _webname = "x-mac-farsi";
|
||||
const int _windowsCodepage = 10014;
|
||||
/// <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;
|
||||
|
||||
const bool browserDisplay = false;
|
||||
const bool browserSave = false;
|
||||
const bool mailNewsDisplay = false;
|
||||
const bool mailNewsSave = false;
|
||||
const bool readOnly = true;
|
||||
const bool singleByte = true;
|
||||
/// <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>
|
||||
static readonly char[] MacFarsiTable =
|
||||
/// <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', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
|
||||
'\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>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserDisplay => browserDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserSave => browserSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsDisplay => mailNewsDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsSave => mailNewsSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding is read-only.
|
||||
/// </summary>
|
||||
/// <value>The is single byte.</value>
|
||||
public override bool IsReadOnly => readOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding uses single-byte code points.
|
||||
/// </summary>
|
||||
public override bool IsSingleByte => singleByte;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the code page identifier of the current Encoding.
|
||||
/// </summary>
|
||||
public override int CodePage => _codepage;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent body tags
|
||||
/// </summary>
|
||||
public override string BodyName => _bodyname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent header tags
|
||||
/// </summary>
|
||||
public override string HeaderName => _headername;
|
||||
|
||||
/// <summary>
|
||||
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
|
||||
/// </summary>
|
||||
public override string WebName => _webname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the human-readable description of the current encoding.
|
||||
/// </summary>
|
||||
public override string EncodingName => _encodingname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
|
||||
/// </summary>
|
||||
public override int WindowsCodePage => _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) =>
|
||||
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 string(GetChars(bytes, index, count));
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Mac Farsi character to an Unicode character
|
||||
/// </summary>
|
||||
/// <returns>Unicode character.</returns>
|
||||
/// <param name="character">Mac Farsi character.</param>
|
||||
static char GetChar(byte character) => MacFarsiTable[character];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Unicode character to an Mac Farsi character
|
||||
/// </summary>
|
||||
/// <summary>Converts a Unicode character to an Mac Farsi character</summary>
|
||||
/// <returns>Mac Farsi character.</returns>
|
||||
/// <param name="character">Unicode character.</param>
|
||||
static byte GetByte(char character)
|
||||
private protected override byte GetByte(char character) => character switch
|
||||
{
|
||||
switch(character)
|
||||
{
|
||||
case '\u0000': return 0x00;
|
||||
case '\u0001': return 0x01;
|
||||
case '\u0002': return 0x02;
|
||||
case '\u0003': return 0x03;
|
||||
case '\u0004': return 0x04;
|
||||
case '\u0005': return 0x05;
|
||||
case '\u0006': return 0x06;
|
||||
case '\u0007': return 0x07;
|
||||
case '\u0008': return 0x08;
|
||||
case '\u0009': return 0x09;
|
||||
case '\u000A': return 0x0A;
|
||||
case '\u000B': return 0x0B;
|
||||
case '\u000C': return 0x0C;
|
||||
case '\u000D': return 0x0D;
|
||||
case '\u000E': return 0x0E;
|
||||
case '\u000F': return 0x0F;
|
||||
case '\u0010': return 0x10;
|
||||
case '\u0011': return 0x11;
|
||||
case '\u0012': return 0x12;
|
||||
case '\u0013': return 0x13;
|
||||
case '\u0014': return 0x14;
|
||||
case '\u0015': return 0x15;
|
||||
case '\u0016': return 0x16;
|
||||
case '\u0017': return 0x17;
|
||||
case '\u0018': return 0x18;
|
||||
case '\u0019': return 0x19;
|
||||
case '\u001A': return 0x1A;
|
||||
case '\u001B': return 0x1B;
|
||||
case '\u001C': return 0x1C;
|
||||
case '\u001D': return 0x1D;
|
||||
case '\u001E': return 0x1E;
|
||||
case '\u001F': return 0x1F;
|
||||
case '\u0020': return 0x20;
|
||||
case '\u0021': return 0x21;
|
||||
case '\u0022': return 0x22;
|
||||
case '\u0023': return 0x23;
|
||||
case '\u0024': return 0x24;
|
||||
case '\u0025': return 0x25;
|
||||
case '\u0026': return 0x26;
|
||||
case '\u0027': return 0x27;
|
||||
case '\u0028': return 0x28;
|
||||
case '\u0029': return 0x29;
|
||||
case '\u002A': return 0x2A;
|
||||
case '\u002B': return 0x2B;
|
||||
case '\u002C': return 0x2C;
|
||||
case '\u002D': return 0x2D;
|
||||
case '\u002E': return 0x2E;
|
||||
case '\u002F': return 0x2F;
|
||||
case '\u0030': return 0x30;
|
||||
case '\u0031': return 0x31;
|
||||
case '\u0032': return 0x32;
|
||||
case '\u0033': return 0x33;
|
||||
case '\u0034': return 0x34;
|
||||
case '\u0035': return 0x35;
|
||||
case '\u0036': return 0x36;
|
||||
case '\u0037': return 0x37;
|
||||
case '\u0038': return 0x38;
|
||||
case '\u0039': return 0x39;
|
||||
case '\u003A': return 0x3A;
|
||||
case '\u003B': return 0x3B;
|
||||
case '\u003C': return 0x3C;
|
||||
case '\u003D': return 0x3D;
|
||||
case '\u003E': return 0x3E;
|
||||
case '\u003F': return 0x3F;
|
||||
case '\u0040': return 0x40;
|
||||
case '\u0041': return 0x41;
|
||||
case '\u0042': return 0x42;
|
||||
case '\u0043': return 0x43;
|
||||
case '\u0044': return 0x44;
|
||||
case '\u0045': return 0x45;
|
||||
case '\u0046': return 0x46;
|
||||
case '\u0047': return 0x47;
|
||||
case '\u0048': return 0x48;
|
||||
case '\u0049': return 0x49;
|
||||
case '\u004A': return 0x4A;
|
||||
case '\u004B': return 0x4B;
|
||||
case '\u004C': return 0x4C;
|
||||
case '\u004D': return 0x4D;
|
||||
case '\u004E': return 0x4E;
|
||||
case '\u004F': return 0x4F;
|
||||
case '\u0050': return 0x50;
|
||||
case '\u0051': return 0x51;
|
||||
case '\u0052': return 0x52;
|
||||
case '\u0053': return 0x53;
|
||||
case '\u0054': return 0x54;
|
||||
case '\u0055': return 0x55;
|
||||
case '\u0056': return 0x56;
|
||||
case '\u0057': return 0x57;
|
||||
case '\u0058': return 0x58;
|
||||
case '\u0059': return 0x59;
|
||||
case '\u005A': return 0x5A;
|
||||
case '\u005B': return 0x5B;
|
||||
case '\u005C': return 0x5C;
|
||||
case '\u005D': return 0x5D;
|
||||
case '\u005E': return 0x5E;
|
||||
case '\u005F': return 0x5F;
|
||||
case '\u0060': return 0x60;
|
||||
case '\u0061': return 0x61;
|
||||
case '\u0062': return 0x62;
|
||||
case '\u0063': return 0x63;
|
||||
case '\u0064': return 0x64;
|
||||
case '\u0065': return 0x65;
|
||||
case '\u0066': return 0x66;
|
||||
case '\u0067': return 0x67;
|
||||
case '\u0068': return 0x68;
|
||||
case '\u0069': return 0x69;
|
||||
case '\u006A': return 0x6A;
|
||||
case '\u006B': return 0x6B;
|
||||
case '\u006C': return 0x6C;
|
||||
case '\u006D': return 0x6D;
|
||||
case '\u006E': return 0x6E;
|
||||
case '\u006F': return 0x6F;
|
||||
case '\u0070': return 0x70;
|
||||
case '\u0071': return 0x71;
|
||||
case '\u0072': return 0x72;
|
||||
case '\u0073': return 0x73;
|
||||
case '\u0074': return 0x74;
|
||||
case '\u0075': return 0x75;
|
||||
case '\u0076': return 0x76;
|
||||
case '\u0077': return 0x77;
|
||||
case '\u0078': return 0x78;
|
||||
case '\u0079': return 0x79;
|
||||
case '\u007A': return 0x7A;
|
||||
case '\u007B': return 0x7B;
|
||||
case '\u007C': return 0x7C;
|
||||
case '\u007D': return 0x7D;
|
||||
case '\u007E': return 0x7E;
|
||||
case '\u007F': return 0x7F;
|
||||
case '\u00C4': return 0x80;
|
||||
case '\u00A0': return 0x81;
|
||||
case '\u00C7': return 0x82;
|
||||
case '\u00C9': return 0x83;
|
||||
case '\u00D1': return 0x84;
|
||||
case '\u00D6': return 0x85;
|
||||
case '\u00DC': return 0x86;
|
||||
case '\u00E1': return 0x87;
|
||||
case '\u00E0': return 0x88;
|
||||
case '\u00E2': return 0x89;
|
||||
case '\u00E4': return 0x8A;
|
||||
case '\u06BA': return 0x8B;
|
||||
case '\u00AB': return 0x8C;
|
||||
case '\u00E7': return 0x8D;
|
||||
case '\u00E9': return 0x8E;
|
||||
case '\u00E8': return 0x8F;
|
||||
case '\u00EA': return 0x90;
|
||||
case '\u00EB': return 0x91;
|
||||
case '\u00ED': return 0x92;
|
||||
case '\u2026': return 0x93;
|
||||
case '\u00EE': return 0x94;
|
||||
case '\u00EF': return 0x95;
|
||||
case '\u00F1': return 0x96;
|
||||
case '\u00F3': return 0x97;
|
||||
case '\u00BB': return 0x98;
|
||||
case '\u00F4': return 0x99;
|
||||
case '\u00F6': return 0x9A;
|
||||
case '\u00F7': return 0x9B;
|
||||
case '\u00FA': return 0x9C;
|
||||
case '\u00F9': return 0x9D;
|
||||
case '\u00FB': return 0x9E;
|
||||
case '\u00FC': return 0x9F;
|
||||
case '\u066A': return 0xA5;
|
||||
case '\u060C': return 0xAC;
|
||||
case '\u06F0': return 0xB0;
|
||||
case '\u06F1': return 0xB1;
|
||||
case '\u06F2': return 0xB2;
|
||||
case '\u06F3': return 0xB3;
|
||||
case '\u06F4': return 0xB4;
|
||||
case '\u06F5': return 0xB5;
|
||||
case '\u06F6': return 0xB6;
|
||||
case '\u06F7': return 0xB7;
|
||||
case '\u06F8': return 0xB8;
|
||||
case '\u06F9': return 0xB9;
|
||||
case '\u061B': return 0xBB;
|
||||
case '\u061F': return 0xBF;
|
||||
case '\u274A': return 0xC0;
|
||||
case '\u0621': return 0xC1;
|
||||
case '\u0622': return 0xC2;
|
||||
case '\u0623': return 0xC3;
|
||||
case '\u0624': return 0xC4;
|
||||
case '\u0625': return 0xC5;
|
||||
case '\u0626': return 0xC6;
|
||||
case '\u0627': return 0xC7;
|
||||
case '\u0628': return 0xC8;
|
||||
case '\u0629': return 0xC9;
|
||||
case '\u062A': return 0xCA;
|
||||
case '\u062B': return 0xCB;
|
||||
case '\u062C': return 0xCC;
|
||||
case '\u062D': return 0xCD;
|
||||
case '\u062E': return 0xCE;
|
||||
case '\u062F': return 0xCF;
|
||||
case '\u0630': return 0xD0;
|
||||
case '\u0631': return 0xD1;
|
||||
case '\u0632': return 0xD2;
|
||||
case '\u0633': return 0xD3;
|
||||
case '\u0634': return 0xD4;
|
||||
case '\u0635': return 0xD5;
|
||||
case '\u0636': return 0xD6;
|
||||
case '\u0637': return 0xD7;
|
||||
case '\u0638': return 0xD8;
|
||||
case '\u0639': return 0xD9;
|
||||
case '\u063A': return 0xDA;
|
||||
case '\u0640': return 0xE0;
|
||||
case '\u0641': return 0xE1;
|
||||
case '\u0642': return 0xE2;
|
||||
case '\u0643': return 0xE3;
|
||||
case '\u0644': return 0xE4;
|
||||
case '\u0645': return 0xE5;
|
||||
case '\u0646': return 0xE6;
|
||||
case '\u0647': return 0xE7;
|
||||
case '\u0648': return 0xE8;
|
||||
case '\u0649': return 0xE9;
|
||||
case '\u064A': return 0xEA;
|
||||
case '\u064B': return 0xEB;
|
||||
case '\u064C': return 0xEC;
|
||||
case '\u064D': return 0xED;
|
||||
case '\u064E': return 0xEE;
|
||||
case '\u064F': return 0xEF;
|
||||
case '\u0650': return 0xF0;
|
||||
case '\u0651': return 0xF1;
|
||||
case '\u0652': return 0xF2;
|
||||
case '\u067E': return 0xF3;
|
||||
case '\u0679': return 0xF4;
|
||||
case '\u0686': return 0xF5;
|
||||
case '\u06D5': return 0xF6;
|
||||
case '\u06A4': return 0xF7;
|
||||
case '\u06AF': return 0xF8;
|
||||
case '\u0688': return 0xF9;
|
||||
case '\u0691': return 0xFA;
|
||||
case '\u0698': return 0xFE;
|
||||
case '\u06D2': return 0xFF;
|
||||
default:
|
||||
// Fallback to '?'
|
||||
return 0x3F;
|
||||
}
|
||||
}
|
||||
'\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
|
||||
};
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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,675 +24,367 @@
|
||||
// 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 Mac Hebrew character encoding of Unicode characters.
|
||||
/// </summary>
|
||||
public class MacHebrew : Encoding
|
||||
/// <summary>Represents an Mac Hebrew character encoding of Unicode characters.</summary>
|
||||
public class MacHebrew : SingleByteEncoding
|
||||
{
|
||||
const string _bodyname = "x-mac-hebrew";
|
||||
const int _codepage = 10005;
|
||||
const string _encodingname = "Hebrew (Mac)";
|
||||
const string _headername = "x-mac-hebrew";
|
||||
const string _webname = "x-mac-hebrew";
|
||||
const int _windowsCodepage = 10005;
|
||||
/// <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;
|
||||
|
||||
const bool browserDisplay = false;
|
||||
const bool browserSave = false;
|
||||
const bool mailNewsDisplay = false;
|
||||
const bool mailNewsSave = false;
|
||||
const bool readOnly = true;
|
||||
const bool singleByte = true;
|
||||
/// <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>
|
||||
|
||||
/// <summary>
|
||||
/// The Macintosh Hebrew to Unicode character map.
|
||||
/// </summary>
|
||||
// TODO: 0x81 => 0x05F2+0x05B7
|
||||
// TODO: 0xC0 => 0xF86A+0x05DC+0x05B9
|
||||
// TODO: 0xDE => 0x05B8+0xF87F
|
||||
static readonly char[] MacHebrewTable =
|
||||
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',
|
||||
'\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>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserDisplay => browserDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserSave => browserSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsDisplay => mailNewsDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsSave => mailNewsSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding is read-only.
|
||||
/// </summary>
|
||||
/// <value>The is single byte.</value>
|
||||
public override bool IsReadOnly => readOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding uses single-byte code points.
|
||||
/// </summary>
|
||||
public override bool IsSingleByte => singleByte;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the code page identifier of the current Encoding.
|
||||
/// </summary>
|
||||
public override int CodePage => _codepage;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent body tags
|
||||
/// </summary>
|
||||
public override string BodyName => _bodyname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent header tags
|
||||
/// </summary>
|
||||
public override string HeaderName => _headername;
|
||||
|
||||
/// <summary>
|
||||
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
|
||||
/// </summary>
|
||||
public override string WebName => _webname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the human-readable description of the current encoding.
|
||||
/// </summary>
|
||||
public override string EncodingName => _encodingname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
|
||||
/// </summary>
|
||||
public override int WindowsCodePage => _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) =>
|
||||
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 string(GetChars(bytes, index, count));
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Mac Hebrew character to an Unicode character
|
||||
/// </summary>
|
||||
/// <returns>Unicode character.</returns>
|
||||
/// <param name="character">Mac Hebrew character.</param>
|
||||
static char GetChar(byte character) => MacHebrewTable[character];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Unicode character to an Mac Hebrew character
|
||||
/// </summary>
|
||||
/// <summary>Converts a Unicode character to an Mac Hebrew character</summary>
|
||||
/// <returns>Mac Hebrew character.</returns>
|
||||
/// <param name="character">Unicode character.</param>
|
||||
static byte GetByte(char character)
|
||||
private protected override byte GetByte(char character) => character switch
|
||||
{
|
||||
switch(character)
|
||||
{
|
||||
case '\u0000': return 0x00;
|
||||
case '\u0001': return 0x01;
|
||||
case '\u0002': return 0x02;
|
||||
case '\u0003': return 0x03;
|
||||
case '\u0004': return 0x04;
|
||||
case '\u0005': return 0x05;
|
||||
case '\u0006': return 0x06;
|
||||
case '\u0007': return 0x07;
|
||||
case '\u0008': return 0x08;
|
||||
case '\u0009': return 0x09;
|
||||
case '\u000A': return 0x0A;
|
||||
case '\u000B': return 0x0B;
|
||||
case '\u000C': return 0x0C;
|
||||
case '\u000D': return 0x0D;
|
||||
case '\u000E': return 0x0E;
|
||||
case '\u000F': return 0x0F;
|
||||
case '\u0010': return 0x10;
|
||||
case '\u0011': return 0x11;
|
||||
case '\u0012': return 0x12;
|
||||
case '\u0013': return 0x13;
|
||||
case '\u0014': return 0x14;
|
||||
case '\u0015': return 0x15;
|
||||
case '\u0016': return 0x16;
|
||||
case '\u0017': return 0x17;
|
||||
case '\u0018': return 0x18;
|
||||
case '\u0019': return 0x19;
|
||||
case '\u001A': return 0x1A;
|
||||
case '\u001B': return 0x1B;
|
||||
case '\u001C': return 0x1C;
|
||||
case '\u001D': return 0x1D;
|
||||
case '\u001E': return 0x1E;
|
||||
case '\u001F': return 0x1F;
|
||||
case '\u0020': return 0x20;
|
||||
case '\u0021': return 0x21;
|
||||
case '\u0022': return 0x22;
|
||||
case '\u0023': return 0x23;
|
||||
case '\u0024': return 0x24;
|
||||
case '\u0025': return 0x25;
|
||||
case '\u0026': return 0x26;
|
||||
case '\u0027': return 0x27;
|
||||
case '\u0028': return 0x28;
|
||||
case '\u0029': return 0x29;
|
||||
case '\u002A': return 0x2A;
|
||||
case '\u002B': return 0x2B;
|
||||
case '\u002C': return 0x2C;
|
||||
case '\u002D': return 0x2D;
|
||||
case '\u002E': return 0x2E;
|
||||
case '\u002F': return 0x2F;
|
||||
case '\u0030': return 0x30;
|
||||
case '\u0031': return 0x31;
|
||||
case '\u0032': return 0x32;
|
||||
case '\u0033': return 0x33;
|
||||
case '\u0034': return 0x34;
|
||||
case '\u0035': return 0x35;
|
||||
case '\u0036': return 0x36;
|
||||
case '\u0037': return 0x37;
|
||||
case '\u0038': return 0x38;
|
||||
case '\u0039': return 0x39;
|
||||
case '\u003A': return 0x3A;
|
||||
case '\u003B': return 0x3B;
|
||||
case '\u003C': return 0x3C;
|
||||
case '\u003D': return 0x3D;
|
||||
case '\u003E': return 0x3E;
|
||||
case '\u003F': return 0x3F;
|
||||
case '\u0040': return 0x40;
|
||||
case '\u0041': return 0x41;
|
||||
case '\u0042': return 0x42;
|
||||
case '\u0043': return 0x43;
|
||||
case '\u0044': return 0x44;
|
||||
case '\u0045': return 0x45;
|
||||
case '\u0046': return 0x46;
|
||||
case '\u0047': return 0x47;
|
||||
case '\u0048': return 0x48;
|
||||
case '\u0049': return 0x49;
|
||||
case '\u004A': return 0x4A;
|
||||
case '\u004B': return 0x4B;
|
||||
case '\u004C': return 0x4C;
|
||||
case '\u004D': return 0x4D;
|
||||
case '\u004E': return 0x4E;
|
||||
case '\u004F': return 0x4F;
|
||||
case '\u0050': return 0x50;
|
||||
case '\u0051': return 0x51;
|
||||
case '\u0052': return 0x52;
|
||||
case '\u0053': return 0x53;
|
||||
case '\u0054': return 0x54;
|
||||
case '\u0055': return 0x55;
|
||||
case '\u0056': return 0x56;
|
||||
case '\u0057': return 0x57;
|
||||
case '\u0058': return 0x58;
|
||||
case '\u0059': return 0x59;
|
||||
case '\u005A': return 0x5A;
|
||||
case '\u005B': return 0x5B;
|
||||
case '\u005C': return 0x5C;
|
||||
case '\u005D': return 0x5D;
|
||||
case '\u005E': return 0x5E;
|
||||
case '\u005F': return 0x5F;
|
||||
case '\u0060': return 0x60;
|
||||
case '\u0061': return 0x61;
|
||||
case '\u0062': return 0x62;
|
||||
case '\u0063': return 0x63;
|
||||
case '\u0064': return 0x64;
|
||||
case '\u0065': return 0x65;
|
||||
case '\u0066': return 0x66;
|
||||
case '\u0067': return 0x67;
|
||||
case '\u0068': return 0x68;
|
||||
case '\u0069': return 0x69;
|
||||
case '\u006A': return 0x6A;
|
||||
case '\u006B': return 0x6B;
|
||||
case '\u006C': return 0x6C;
|
||||
case '\u006D': return 0x6D;
|
||||
case '\u006E': return 0x6E;
|
||||
case '\u006F': return 0x6F;
|
||||
case '\u0070': return 0x70;
|
||||
case '\u0071': return 0x71;
|
||||
case '\u0072': return 0x72;
|
||||
case '\u0073': return 0x73;
|
||||
case '\u0074': return 0x74;
|
||||
case '\u0075': return 0x75;
|
||||
case '\u0076': return 0x76;
|
||||
case '\u0077': return 0x77;
|
||||
case '\u0078': return 0x78;
|
||||
case '\u0079': return 0x79;
|
||||
case '\u007A': return 0x7A;
|
||||
case '\u007B': return 0x7B;
|
||||
case '\u007C': return 0x7C;
|
||||
case '\u007D': return 0x7D;
|
||||
case '\u007E': return 0x7E;
|
||||
case '\u007F': return 0x7F;
|
||||
case '\u00C4': return 0x80;
|
||||
case '\u00C7': return 0x82;
|
||||
case '\u00C9': return 0x83;
|
||||
case '\u00D1': return 0x84;
|
||||
case '\u00D6': return 0x85;
|
||||
case '\u00DC': return 0x86;
|
||||
case '\u00E1': return 0x87;
|
||||
case '\u00E0': return 0x88;
|
||||
case '\u00E2': return 0x89;
|
||||
case '\u00E4': return 0x8A;
|
||||
case '\u00E3': return 0x8B;
|
||||
case '\u00E5': return 0x8C;
|
||||
case '\u00E7': return 0x8D;
|
||||
case '\u00E9': return 0x8E;
|
||||
case '\u00E8': return 0x8F;
|
||||
case '\u00EA': return 0x90;
|
||||
case '\u00EB': return 0x91;
|
||||
case '\u00ED': return 0x92;
|
||||
case '\u00EC': return 0x93;
|
||||
case '\u00EE': return 0x94;
|
||||
case '\u00EF': return 0x95;
|
||||
case '\u00F1': return 0x96;
|
||||
case '\u00F3': return 0x97;
|
||||
case '\u00F2': return 0x98;
|
||||
case '\u00F4': return 0x99;
|
||||
case '\u00F6': return 0x9A;
|
||||
case '\u00F5': return 0x9B;
|
||||
case '\u00FA': return 0x9C;
|
||||
case '\u00F9': return 0x9D;
|
||||
case '\u00FB': return 0x9E;
|
||||
case '\u00FC': return 0x9F;
|
||||
case '\u20AA': return 0xA6;
|
||||
case '\u201E': return 0xC1;
|
||||
case '\uF89B': return 0xC2;
|
||||
case '\uF89C': return 0xC3;
|
||||
case '\uF89D': return 0xC4;
|
||||
case '\uF89E': return 0xC5;
|
||||
case '\u05BC': return 0xC6;
|
||||
case '\uFB4B': return 0xC7;
|
||||
case '\uFB35': return 0xC8;
|
||||
case '\u2026': return 0xC9;
|
||||
case '\u00A0': return 0xCA;
|
||||
case '\u05B8': return 0xCB;
|
||||
case '\u05B7': return 0xCC;
|
||||
case '\u05B5': return 0xCD;
|
||||
case '\u05B6': return 0xCE;
|
||||
case '\u05B4': return 0xCF;
|
||||
case '\u2013': return 0xD0;
|
||||
case '\u2014': return 0xD1;
|
||||
case '\u201C': return 0xD2;
|
||||
case '\u201D': return 0xD3;
|
||||
case '\u2018': return 0xD4;
|
||||
case '\u2019': return 0xD5;
|
||||
case '\uFB2A': return 0xD6;
|
||||
case '\uFB2B': return 0xD7;
|
||||
case '\u05BF': return 0xD8;
|
||||
case '\u05B0': return 0xD9;
|
||||
case '\u05B2': return 0xDA;
|
||||
case '\u05B1': return 0xDB;
|
||||
case '\u05BB': return 0xDC;
|
||||
case '\u05B9': return 0xDD;
|
||||
case '\u05B3': return 0xDF;
|
||||
case '\u05D0': return 0xE0;
|
||||
case '\u05D1': return 0xE1;
|
||||
case '\u05D2': return 0xE2;
|
||||
case '\u05D3': return 0xE3;
|
||||
case '\u05D4': return 0xE4;
|
||||
case '\u05D5': return 0xE5;
|
||||
case '\u05D6': return 0xE6;
|
||||
case '\u05D7': return 0xE7;
|
||||
case '\u05D8': return 0xE8;
|
||||
case '\u05D9': return 0xE9;
|
||||
case '\u05DA': return 0xEA;
|
||||
case '\u05DB': return 0xEB;
|
||||
case '\u05DC': return 0xEC;
|
||||
case '\u05DD': return 0xED;
|
||||
case '\u05DE': return 0xEE;
|
||||
case '\u05DF': return 0xEF;
|
||||
case '\u05E0': return 0xF0;
|
||||
case '\u05E1': return 0xF1;
|
||||
case '\u05E2': return 0xF2;
|
||||
case '\u05E3': return 0xF3;
|
||||
case '\u05E4': return 0xF4;
|
||||
case '\u05E5': return 0xF5;
|
||||
case '\u05E6': return 0xF6;
|
||||
case '\u05E7': return 0xF7;
|
||||
case '\u05E8': return 0xF8;
|
||||
case '\u05E9': return 0xF9;
|
||||
case '\u05EA': return 0xFA;
|
||||
default:
|
||||
// Fallback to '?'
|
||||
return 0x3F;
|
||||
}
|
||||
}
|
||||
'\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
|
||||
};
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Michael Drüing <darkstar@drueing.de>
|
||||
//
|
||||
// Copyright © 2016-2019 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,455 +24,187 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Claunia.Encoding
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an Commodore PET Standard Code for Information Interchange (aka CBM ASCII) character encoding of Unicode
|
||||
/// characters.
|
||||
/// Represents an Commodore PET Standard Code for Information Interchange (aka CBM ASCII) character encoding of
|
||||
/// Unicode characters.
|
||||
/// </summary>
|
||||
public class PETSCII : Encoding
|
||||
public class Petscii : SingleByteEncodingWithRunes
|
||||
{
|
||||
const string _bodyname = "petscii";
|
||||
const int _codepage = 0;
|
||||
const string _encodingname = "Commodore PET Standard Code for Information Interchange";
|
||||
const string _headername = "petscii";
|
||||
const string _webname = "";
|
||||
const int _windowsCodepage = 0;
|
||||
/// <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;
|
||||
|
||||
const bool browserDisplay = false;
|
||||
const bool browserSave = false;
|
||||
const bool mailNewsDisplay = false;
|
||||
const bool mailNewsSave = false;
|
||||
const bool readOnly = false;
|
||||
const bool singleByte = true;
|
||||
/// <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>
|
||||
/// <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 =
|
||||
protected override Rune[] CharTable => new[]
|
||||
{
|
||||
// 0x00
|
||||
'\u0000', '\u0000', '\u0000', '\u0003', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u000A', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0008', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
|
||||
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
|
||||
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
|
||||
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
|
||||
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
|
||||
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
|
||||
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
|
||||
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
|
||||
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
|
||||
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
|
||||
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
|
||||
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
|
||||
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
|
||||
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
|
||||
'\u0058', '\u0059', '\u005A', '\u005B', '\u00A3', '\u005D', '\u2191', '\u2190',
|
||||
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
|
||||
'\u2500', '\u2660', '\u2502', '\u2500', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u256E', '\u2570', '\u256F', '\u0000', '\u2572', '\u2571', '\u0000',
|
||||
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
|
||||
'\u0000', '\u2022', '\u0000', '\u2665', '\u0000', '\u256D', '\u2573', '\u25CB',
|
||||
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
|
||||
'\u2663', '\u0000', '\u2666', '\u253C', '\u0000', '\u2502', '\u03C0', '\u25E5',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u2028', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u00A0', '\u258C', '\u2584', '\u2594', '\u2581', '\u258E', '\u2592', '\u0000',
|
||||
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
|
||||
'\u0000', '\u25E4', '\u258A', '\u251C', '\u2597', '\u2514', '\u2510', '\u2582',
|
||||
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
|
||||
'\u250C', '\u2534', '\u252C', '\u2524', '\u258E', '\u258D', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u2583', '\u0000', '\u2596', '\u259D', '\u2518', '\u2598', '\u259A',
|
||||
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)
|
||||
'\u2500', '\u2660', '\u2502', '\u2500', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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)
|
||||
'\u0000', '\u256E', '\u2570', '\u256F', '\u0000', '\u2572', '\u2571', '\u0000',
|
||||
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)
|
||||
'\u0000', '\u2022', '\u0000', '\u2665', '\u0000', '\u256D', '\u2573', '\u25CB',
|
||||
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)
|
||||
'\u2663', '\u0000', '\u2666', '\u253C', '\u0000', '\u2502', '\u03C0', '\u25E5',
|
||||
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)
|
||||
'\u00A0', '\u258C', '\u2584', '\u2594', '\u2581', '\u258E', '\u2592', '\u0000',
|
||||
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)
|
||||
'\u0000', '\u25E4', '\u258A', '\u251C', '\u2597', '\u2514', '\u2510', '\u2582',
|
||||
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)
|
||||
'\u250C', '\u2534', '\u252C', '\u2524', '\u258E', '\u258D', '\u0000', '\u0000',
|
||||
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)
|
||||
'\u0000', '\u2583', '\u0000', '\u2596', '\u259D', '\u2518', '\u2598', '\u259A'
|
||||
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>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserDisplay => browserDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserSave => browserSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsDisplay => mailNewsDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsSave => mailNewsSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding is read-only.
|
||||
/// </summary>
|
||||
public override bool IsReadOnly => readOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding uses single-byte code points.
|
||||
/// </summary>
|
||||
public override bool IsSingleByte => singleByte;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the code page identifier of the current Encoding.
|
||||
/// </summary>
|
||||
public override int CodePage => _codepage;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent body tags
|
||||
/// </summary>
|
||||
public override string BodyName => _bodyname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent header tags
|
||||
/// </summary>
|
||||
public override string HeaderName => _headername;
|
||||
|
||||
/// <summary>
|
||||
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
|
||||
/// </summary>
|
||||
public override string WebName => _webname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the human-readable description of the current encoding.
|
||||
/// </summary>
|
||||
public override string EncodingName => _encodingname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
|
||||
/// </summary>
|
||||
public override int WindowsCodePage => _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) =>
|
||||
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 string(GetChars(bytes, index, count));
|
||||
|
||||
/// <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) => PETSCIITable[character];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Unicode character to an PETSCII character
|
||||
/// </summary>
|
||||
/// <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)
|
||||
private protected override byte GetByte(Rune character)
|
||||
{
|
||||
if(character == 0x0000) return 0x3F;
|
||||
if(character.Value == 0x0000)
|
||||
return 0x3F;
|
||||
|
||||
for(int i = 0; i < 256; i++)
|
||||
|
||||
// TODO: convert this to a gigantic switch statement too?
|
||||
if(PETSCIITable[i] == character)
|
||||
if(CharTable[i] == character)
|
||||
return (byte)i;
|
||||
|
||||
// Fallback to '?'
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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
|
||||
@@ -26,110 +26,108 @@
|
||||
|
||||
namespace Claunia.Encoding
|
||||
{
|
||||
/// <summary>
|
||||
/// Class containing pangrams for several languages that can be used to test encoding.
|
||||
/// </summary>
|
||||
/// <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 =
|
||||
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.";
|
||||
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";
|
||||
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 =
|
||||
public const string BRETON =
|
||||
"Yec’hed 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 = "Хълцащ змей плюе шофьор стигнал чуждия бивак.";
|
||||
public const string BULGARIAN = "Хълцащ змей плюе шофьор стигнал чуждия бивак.";
|
||||
/// <summary>A pangram that contains all (or most) Catalan characters.</summary>
|
||||
public const string Catalan =
|
||||
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 d’onze kWh.";
|
||||
/// <summary>A pangram that contains Traditional Chinese characters.</summary>
|
||||
public const string ChineseTraditional = "視野無限廣,窗外有藍天";
|
||||
public const string CHINESE_TRADITIONAL = "視野無限廣,窗外有藍天";
|
||||
/// <summary>A pangram that contains Simplified Chinese characters.</summary>
|
||||
public const string ChineseSimplified = "Innovation in China 中国智造,慧及全球";
|
||||
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.";
|
||||
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 =
|
||||
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 =
|
||||
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 = "Pa’s wijze lynx bezag vroom het fikse aquaduct.";
|
||||
public const string DUTCH = "Pa’s 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.";
|
||||
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.";
|
||||
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.";
|
||||
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 =
|
||||
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 =
|
||||
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 =
|
||||
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.";
|
||||
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 =
|
||||
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 =
|
||||
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.";
|
||||
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.";
|
||||
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";
|
||||
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 = "色は匂へど 散りぬるを 我が世誰ぞ 常ならむ 有為の奥山 今日越えて 浅き夢見じ 酔ひもせず(ん)";
|
||||
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 = "키스의 고유조건은 입술끼리 만나야 하고 특별한 기술은 필요치 않다";
|
||||
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.";
|
||||
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ą";
|
||||
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 = "Ѕидарски пејзаж: шугав билмез со чудење џвака ќофте и кељ на туѓ цех.";
|
||||
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";
|
||||
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!";
|
||||
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 =
|
||||
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.";
|
||||
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 =
|
||||
public const string RUSSIAN =
|
||||
"Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства.";
|
||||
/// <summary>A pangram that contains all (or most) Scottish Gaelic characters.</summary>
|
||||
public const string Scottish = "Mus d’fhàg Cèit-Ùna ròp Ì le ob.";
|
||||
public const string SCOTTISH = "Mus d’fhà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.";
|
||||
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 =
|
||||
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.";
|
||||
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 =
|
||||
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.";
|
||||
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.";
|
||||
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.";
|
||||
public const string WELSH = "Parciais fy jac codi baw hud llawn dŵr ger tŷ Mabon.";
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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
|
||||
@@ -28,229 +28,126 @@ using System;
|
||||
|
||||
namespace Claunia.Encoding
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an Radix-50 (PDP-11) character encoding of Unicode characters.
|
||||
/// </summary>
|
||||
public class Radix50 : Encoding
|
||||
/// <summary>Represents an Radix-50 (PDP-11) character encoding of Unicode characters.</summary>
|
||||
public class Radix50 : SingleByteEncoding
|
||||
{
|
||||
const string _bodyname = "radix50";
|
||||
const int _codepage = 0;
|
||||
const string _encodingname = "Western European (Radix-50)";
|
||||
const string _headername = "radix50";
|
||||
const string _webname = "";
|
||||
const int _windowsCodepage = 0;
|
||||
/// <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;
|
||||
|
||||
const bool browserDisplay = false;
|
||||
const bool browserSave = false;
|
||||
const bool mailNewsDisplay = false;
|
||||
const bool mailNewsSave = false;
|
||||
const bool readOnly = false;
|
||||
const bool singleByte = false;
|
||||
/// <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>
|
||||
static readonly char[] Radix50Table =
|
||||
/// <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>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserDisplay => browserDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserSave => browserSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsDisplay => mailNewsDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsSave => mailNewsSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding is read-only.
|
||||
/// </summary>
|
||||
/// <value>The is single byte.</value>
|
||||
public override bool IsReadOnly => readOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding uses single-byte code points.
|
||||
/// </summary>
|
||||
public override bool IsSingleByte => singleByte;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the code page identifier of the current Encoding.
|
||||
/// </summary>
|
||||
public override int CodePage => _codepage;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent body tags
|
||||
/// </summary>
|
||||
public override string BodyName => _bodyname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent header tags
|
||||
/// </summary>
|
||||
public override string HeaderName => _headername;
|
||||
|
||||
/// <summary>
|
||||
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
|
||||
/// </summary>
|
||||
public override string WebName => _webname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the human-readable description of the current encoding.
|
||||
/// </summary>
|
||||
public override string EncodingName => _encodingname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
|
||||
/// </summary>
|
||||
public override int WindowsCodePage => _windowsCodepage;
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the number of bytes produced by encoding the characters in the specified <see cref="string" />.
|
||||
/// </summary>
|
||||
/// <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));
|
||||
if(s == null)
|
||||
throw new ArgumentNullException(nameof(s));
|
||||
|
||||
return s.Length * 6 % 8 > 0 ? s.Length * 6 / 8 + 1 : s.Length * 6 / 8;
|
||||
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>
|
||||
/// <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(chars == null)
|
||||
throw new ArgumentNullException(nameof(chars));
|
||||
|
||||
if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
|
||||
if(index < 0 ||
|
||||
index >= chars.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
|
||||
if(count < 0 || index + count > 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;
|
||||
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>
|
||||
/// <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));
|
||||
if(chars == null)
|
||||
throw new ArgumentNullException(nameof(chars));
|
||||
|
||||
return chars.Length * 6 % 8 > 0 ? chars.Length * 6 / 8 + 1 : chars.Length * 6 / 8;
|
||||
return chars.Length * 6 % 8 > 0 ? (chars.Length * 6 / 8) + 1 : chars.Length * 6 / 8;
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// <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(chars == null)
|
||||
throw new ArgumentNullException(nameof(chars));
|
||||
|
||||
if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
|
||||
if(index < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
|
||||
if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
|
||||
if(count < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
|
||||
if(count + index > chars.Length) 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];
|
||||
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++)
|
||||
@@ -260,27 +157,35 @@ namespace Claunia.Encoding
|
||||
switch(i % 4)
|
||||
{
|
||||
case 0:
|
||||
if(outPos >= bytes.Length) break;
|
||||
if(outPos >= bytes.Length)
|
||||
break;
|
||||
|
||||
bytes[outPos] = (byte)(thisByte << 2);
|
||||
|
||||
break;
|
||||
case 1:
|
||||
if(outPos + 1 >= bytes.Length) break;
|
||||
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;
|
||||
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;
|
||||
if(outPos + 2 >= bytes.Length)
|
||||
break;
|
||||
|
||||
bytes[outPos + 2] += (byte)(thisByte & 0x3F);
|
||||
outPos += 3;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -288,126 +193,77 @@ namespace Claunia.Encoding
|
||||
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>
|
||||
/// <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(bytes == null)
|
||||
throw new ArgumentNullException(nameof(bytes));
|
||||
|
||||
if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
|
||||
if(index < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
|
||||
if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
|
||||
if(count < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
|
||||
if(count + index > bytes.Length) 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 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>
|
||||
/// <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(bytes == null)
|
||||
throw new ArgumentNullException(nameof(bytes));
|
||||
|
||||
if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
|
||||
if(index < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
|
||||
if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
|
||||
if(count < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
|
||||
if(count + index > bytes.Length) 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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -415,113 +271,79 @@ namespace Claunia.Encoding
|
||||
return chars;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the maximum number of bytes produced by encoding the specified number of characters.
|
||||
/// </summary>
|
||||
/// <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));
|
||||
if(charCount < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(charCount));
|
||||
|
||||
return charCount * 6 % 8 > 0 ? charCount * 6 / 8 + 1 : charCount * 6 / 8;
|
||||
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>
|
||||
/// <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));
|
||||
if(byteCount < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(byteCount));
|
||||
|
||||
return byteCount * 8 / 6;
|
||||
}
|
||||
|
||||
/// <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 string(GetChars(bytes, index, count));
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Apple II character to an Unicode character
|
||||
/// </summary>
|
||||
/// <summary>Converts a Apple II character to an Unicode character</summary>
|
||||
/// <returns>Unicode character.</returns>
|
||||
/// <param name="character">Apple II character.</param>
|
||||
static char GetChar(byte character) => Radix50Table[character & 0x3F];
|
||||
char GetChar(byte character) => CharTable[character & 0x3F];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Unicode character to an Apple II character
|
||||
/// </summary>
|
||||
/// <summary>Converts a Unicode character to an Apple II character</summary>
|
||||
/// <returns>Apple II character.</returns>
|
||||
/// <param name="character">Unicode character.</param>
|
||||
static byte GetByte(char character)
|
||||
private protected override byte GetByte(char character) => character switch
|
||||
{
|
||||
switch(character)
|
||||
{
|
||||
case '\u0020': return 0x00;
|
||||
case '\u0041': return 0x01;
|
||||
case '\u0042': return 0x02;
|
||||
case '\u0043': return 0x03;
|
||||
case '\u0044': return 0x04;
|
||||
case '\u0045': return 0x05;
|
||||
case '\u0046': return 0x06;
|
||||
case '\u0047': return 0x07;
|
||||
case '\u0048': return 0x08;
|
||||
case '\u0049': return 0x09;
|
||||
case '\u004A': return 0x0A;
|
||||
case '\u004B': return 0x0B;
|
||||
case '\u004C': return 0x0C;
|
||||
case '\u004D': return 0x0D;
|
||||
case '\u004E': return 0x0E;
|
||||
case '\u004F': return 0x0F;
|
||||
case '\u0050': return 0x10;
|
||||
case '\u0051': return 0x11;
|
||||
case '\u0052': return 0x12;
|
||||
case '\u0053': return 0x13;
|
||||
case '\u0054': return 0x14;
|
||||
case '\u0055': return 0x15;
|
||||
case '\u0056': return 0x16;
|
||||
case '\u0057': return 0x17;
|
||||
case '\u0058': return 0x18;
|
||||
case '\u0059': return 0x19;
|
||||
case '\u005A': return 0x1A;
|
||||
case '\u0024': return 0x1B;
|
||||
case '\u002E': return 0x1C;
|
||||
case '\u0025': return 0x1D;
|
||||
case '\u0030': return 0x1E;
|
||||
case '\u0031': return 0x1F;
|
||||
case '\u0032': return 0x20;
|
||||
case '\u0033': return 0x21;
|
||||
case '\u0034': return 0x22;
|
||||
case '\u0035': return 0x23;
|
||||
case '\u0036': return 0x24;
|
||||
case '\u0037': return 0x25;
|
||||
case '\u0038': return 0x26;
|
||||
case '\u0039': return 0x27;
|
||||
default:
|
||||
// Fallback to '.'
|
||||
return 0x1C;
|
||||
}
|
||||
}
|
||||
'\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
|
||||
};
|
||||
}
|
||||
}
|
||||
343
Claunia.Encoding/SingleByteEncoding.cs
Normal file
343
Claunia.Encoding/SingleByteEncoding.cs
Normal file
@@ -0,0 +1,343 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
375
Claunia.Encoding/SingleByteEncodingWithRunes.cs
Normal file
375
Claunia.Encoding/SingleByteEncodingWithRunes.cs
Normal file
@@ -0,0 +1,375 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
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(var 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);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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,528 +24,255 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Claunia.Encoding
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a ZX80 character encoding of Unicode characters.
|
||||
/// </summary>
|
||||
public class ZX80 : Encoding
|
||||
/// <summary>Represents a ZX80 character encoding of Unicode characters.</summary>
|
||||
public class Zx80 : SingleByteEncodingWithRunes
|
||||
{
|
||||
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;
|
||||
/// <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;
|
||||
|
||||
const bool browserDisplay = false;
|
||||
const bool browserSave = false;
|
||||
const bool mailNewsDisplay = false;
|
||||
const bool mailNewsSave = false;
|
||||
const bool readOnly = false;
|
||||
const bool singleByte = true;
|
||||
/// <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>
|
||||
static readonly char[] ZX80Table =
|
||||
/// <summary>The ZX80 to Unicode character map.</summary>
|
||||
protected override Rune[] CharTable => new[]
|
||||
{
|
||||
// 0x00
|
||||
'\u0020', '\u0022', '\u258C', '\u2584', '\u2598', '\u259D', '\u2596', '\u2597',
|
||||
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
|
||||
'\u259E', '\u2592', '\uFFFD', '\uFFFD', '\u00A3', '\u0024', '\u003A', '\u003F',
|
||||
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
|
||||
'\u0028', '\u0029', '\u002D', '\u002B', '\u002A', '\u002F', '\u003D', '\u003E',
|
||||
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
|
||||
'\u003C', '\u003B', '\u002C', '\u002E', '\u0030', '\u0031', '\u0032', '\u0033',
|
||||
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
|
||||
'\u0034', '\u0035', '\u0036', '\u0037', '\u0038', '\u0039', '\u0041', '\u0042',
|
||||
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
|
||||
'\u0043', '\u0044', '\u0045', '\u0046', '\u0047', '\u0048', '\u0049', '\u004A',
|
||||
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
|
||||
'\u004B', '\u004C', '\u004D', '\u004E', '\u004F', '\u0050', '\u0051', '\u0052',
|
||||
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
|
||||
'\u0053', '\u0054', '\u0055', '\u0056', '\u0057', '\u0058', '\u0059', '\u005A',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\u000D', '\uFFFD', '\u000A', '\u0008',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u2588', '\uFFFD', '\u2590', '\u2580', '\u2599', '\u259C', '\u259B', '\u259A',
|
||||
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
|
||||
'\u2592', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
|
||||
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
|
||||
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
|
||||
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
|
||||
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
|
||||
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
|
||||
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
|
||||
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
|
||||
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
|
||||
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
|
||||
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
|
||||
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
|
||||
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
|
||||
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
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
|
||||
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
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
|
||||
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
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
|
||||
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
|
||||
'\uFFFF', '\u0000', '\u0000', '\uFFFF', '\uFFFF', '\u0000', '\uFFFF', '\uFFFF',
|
||||
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
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\u0000'
|
||||
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>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserDisplay => browserDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserSave => browserSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsDisplay => mailNewsDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsSave => mailNewsSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding is read-only.
|
||||
/// </summary>
|
||||
/// <value>The is single byte.</value>
|
||||
public override bool IsReadOnly => readOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding uses single-byte code points.
|
||||
/// </summary>
|
||||
public override bool IsSingleByte => singleByte;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the code page identifier of the current Encoding.
|
||||
/// </summary>
|
||||
public override int CodePage => _codepage;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent body tags
|
||||
/// </summary>
|
||||
public override string BodyName => _bodyname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent header tags
|
||||
/// </summary>
|
||||
public override string HeaderName => _headername;
|
||||
|
||||
/// <summary>
|
||||
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
|
||||
/// </summary>
|
||||
public override string WebName => _webname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the human-readable description of the current encoding.
|
||||
/// </summary>
|
||||
public override string EncodingName => _encodingname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
|
||||
/// </summary>
|
||||
public override int WindowsCodePage => _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) =>
|
||||
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 string(GetChars(bytes, index, count));
|
||||
|
||||
/// <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) => ZX80Table[character];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Unicode character to an ZX80 character
|
||||
/// </summary>
|
||||
/// <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)
|
||||
private protected override byte GetByte(Rune character) => character.Value switch
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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,528 +24,255 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Claunia.Encoding
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a ZX81 character encoding of Unicode characters.
|
||||
/// </summary>
|
||||
public class ZX81 : Encoding
|
||||
/// <summary>Represents a ZX81 character encoding of Unicode characters.</summary>
|
||||
public class Zx81 : SingleByteEncodingWithRunes
|
||||
{
|
||||
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;
|
||||
/// <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;
|
||||
|
||||
const bool browserDisplay = false;
|
||||
const bool browserSave = false;
|
||||
const bool mailNewsDisplay = false;
|
||||
const bool mailNewsSave = false;
|
||||
const bool readOnly = false;
|
||||
const bool singleByte = true;
|
||||
/// <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>
|
||||
static readonly char[] ZX81Table =
|
||||
/// <summary>The ZX81 to Unicode character map.</summary>
|
||||
protected override Rune[] CharTable => new[]
|
||||
{
|
||||
// 0x00
|
||||
'\u0020', '\u2598', '\u259D', '\u2580', '\u2596', '\u258C', '\u259E', '\u259B',
|
||||
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
|
||||
'\u2592', '\uFFFD', '\uFFFD', '\u0022', '\u00A3', '\u0024', '\u003A', '\u003F',
|
||||
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
|
||||
'\u0028', '\u0029', '\u003E', '\u003C', '\u003D', '\u002B', '\u002D', '\u002A',
|
||||
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
|
||||
'\u002F', '\u003B', '\u002C', '\u002E', '\u0030', '\u0031', '\u0032', '\u0033',
|
||||
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
|
||||
'\u0034', '\u0035', '\u0036', '\u0037', '\u0038', '\u0039', '\u0041', '\u0042',
|
||||
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
|
||||
'\u0043', '\u0044', '\u0045', '\u0046', '\u0047', '\u0048', '\u0049', '\u004A',
|
||||
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
|
||||
'\u004B', '\u004C', '\u004D', '\u004E', '\u004F', '\u0050', '\u0051', '\u0052',
|
||||
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
|
||||
'\u0053', '\u0054', '\u0055', '\u0056', '\u0057', '\u0058', '\u0059', '\u005A',
|
||||
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
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
|
||||
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
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\u000A', '\u0008',
|
||||
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
|
||||
'\uFFFF', '\uFFFF', '\u0000', '\u0000', '\u0000', '\u0000', '\uFFFF', '\uFFFF',
|
||||
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
|
||||
'\u2588', '\u259F', '\u2599', '\u2584', '\u259C', '\u2590', '\u259A', '\u2597',
|
||||
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
|
||||
'\u2592', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
|
||||
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
|
||||
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
|
||||
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
|
||||
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
|
||||
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
|
||||
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
|
||||
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
|
||||
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
|
||||
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
|
||||
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
|
||||
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
|
||||
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
|
||||
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
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\u0000', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
|
||||
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
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
|
||||
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
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
|
||||
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
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
|
||||
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
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
|
||||
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
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
|
||||
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
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
|
||||
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
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF'
|
||||
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>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserDisplay => browserDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserSave => browserSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsDisplay => mailNewsDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsSave => mailNewsSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding is read-only.
|
||||
/// </summary>
|
||||
/// <value>The is single byte.</value>
|
||||
public override bool IsReadOnly => readOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding uses single-byte code points.
|
||||
/// </summary>
|
||||
public override bool IsSingleByte => singleByte;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the code page identifier of the current Encoding.
|
||||
/// </summary>
|
||||
public override int CodePage => _codepage;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent body tags
|
||||
/// </summary>
|
||||
public override string BodyName => _bodyname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent header tags
|
||||
/// </summary>
|
||||
public override string HeaderName => _headername;
|
||||
|
||||
/// <summary>
|
||||
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
|
||||
/// </summary>
|
||||
public override string WebName => _webname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the human-readable description of the current encoding.
|
||||
/// </summary>
|
||||
public override string EncodingName => _encodingname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
|
||||
/// </summary>
|
||||
public override int WindowsCodePage => _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) =>
|
||||
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 string(GetChars(bytes, index, count));
|
||||
|
||||
/// <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) => ZX81Table[character];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Unicode character to an ZX81 character
|
||||
/// </summary>
|
||||
/// <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)
|
||||
private protected override byte GetByte(Rune character) => character.Value switch
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
// Author:
|
||||
// Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Copyright © 2016-2019 Natalia Portillo
|
||||
// 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,568 +24,256 @@
|
||||
// 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 ZX Spectrum character encoding of Unicode characters.
|
||||
/// </summary>
|
||||
public class ZXSpectrum : Encoding
|
||||
/// <summary>Represents an ZX Spectrum character encoding of Unicode characters.</summary>
|
||||
public class ZxSpectrum : SingleByteEncoding
|
||||
{
|
||||
const string _bodyname = "spectrum";
|
||||
const int _codepage = 0;
|
||||
const string _encodingname = "Sinclair ZX Spectrum character set";
|
||||
const string _headername = "spectrum";
|
||||
const string _webname = "";
|
||||
const int _windowsCodepage = 0;
|
||||
/// <inheritdoc />
|
||||
public override string BodyName => "spectrum";
|
||||
/// <inheritdoc />
|
||||
public override int CodePage => 0;
|
||||
/// <inheritdoc />
|
||||
public override string EncodingName => "Sinclair ZX Spectrum character set";
|
||||
/// <inheritdoc />
|
||||
public override string HeaderName => "spectrum";
|
||||
/// <inheritdoc />
|
||||
public override string WebName => "";
|
||||
/// <inheritdoc />
|
||||
public override 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;
|
||||
/// <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 ZX Spectrum to Unicode character map.
|
||||
/// </summary>
|
||||
static readonly char[] ZXSpectrumTable =
|
||||
/// <summary>The ZX Spectrum to Unicode character map.</summary>
|
||||
protected override char[] CharTable => new[]
|
||||
{
|
||||
// 0x00
|
||||
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0009', '\u0000',
|
||||
|
||||
// 0x08
|
||||
'\uFFFF', '\uFFFF', '\u0000', '\u0000', '\u0000', '\u000D', '\uFFFF', '\u0000',
|
||||
|
||||
// 0x10
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\u0009',
|
||||
|
||||
// 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', '\u005C', '\u005D', '\u2191', '\u005F',
|
||||
|
||||
// 0x60
|
||||
'\u00A3', '\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', '\u00A9',
|
||||
|
||||
// 0x80
|
||||
'\u0020', '\u259D', '\u2598', '\u2580', '\u2597', '\u2590', '\u259A', '\u259C',
|
||||
|
||||
// 0x88
|
||||
'\u2596', '\u259E', '\u258C', '\u259B', '\u2584', '\u259F', '\u2599', '\u2588',
|
||||
|
||||
// 0x90
|
||||
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
|
||||
|
||||
// 0x98
|
||||
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
|
||||
|
||||
// 0xA0
|
||||
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFF', '\uFFFF', '\uFFFF',
|
||||
|
||||
// 0xA8
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
|
||||
|
||||
// 0xB0
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
|
||||
|
||||
// 0xB8
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
|
||||
|
||||
// 0xC0
|
||||
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\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>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserDisplay => browserDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsBrowserSave => browserSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsDisplay => mailNewsDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
|
||||
/// </summary>
|
||||
public override bool IsMailNewsSave => mailNewsSave;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding is read-only.
|
||||
/// </summary>
|
||||
/// <value>The is single byte.</value>
|
||||
public override bool IsReadOnly => readOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current encoding uses single-byte code points.
|
||||
/// </summary>
|
||||
public override bool IsSingleByte => singleByte;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the code page identifier of the current Encoding.
|
||||
/// </summary>
|
||||
public override int CodePage => _codepage;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent body tags
|
||||
/// </summary>
|
||||
public override string BodyName => _bodyname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a name for the current encoding that can be used with mail agent header tags
|
||||
/// </summary>
|
||||
public override string HeaderName => _headername;
|
||||
|
||||
/// <summary>
|
||||
/// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
|
||||
/// </summary>
|
||||
public override string WebName => _webname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the human-readable description of the current encoding.
|
||||
/// </summary>
|
||||
public override string EncodingName => _encodingname;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Windows operating system code page that most closely corresponds to the current encoding.
|
||||
/// </summary>
|
||||
public override int WindowsCodePage => _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) =>
|
||||
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 string(GetChars(bytes, index, count));
|
||||
|
||||
/// <summary>
|
||||
/// Converts a ZX Spectrum character to an Unicode character
|
||||
/// </summary>
|
||||
/// <returns>Unicode character.</returns>
|
||||
/// <param name="character">ZX Spectrum character.</param>
|
||||
static char GetChar(byte character) => ZXSpectrumTable[character];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Unicode character to an ZX Spectrum character
|
||||
/// </summary>
|
||||
/// <summary>Converts a Unicode character to an ZX Spectrum character</summary>
|
||||
/// <returns>ZX Spectrum character.</returns>
|
||||
/// <param name="character">Unicode character.</param>
|
||||
static byte GetByte(char character)
|
||||
private protected override byte GetByte(char character) => character switch
|
||||
{
|
||||
switch(character)
|
||||
{
|
||||
case '\u0009': return 0x06;
|
||||
case '\u000D': return 0x0D;
|
||||
case '\u0020': return 0x20;
|
||||
case '\u0021': return 0x21;
|
||||
case '\u0022': return 0x22;
|
||||
case '\u0023': return 0x23;
|
||||
case '\u0024': return 0x24;
|
||||
case '\u0025': return 0x25;
|
||||
case '\u0026': return 0x26;
|
||||
case '\u0027': return 0x27;
|
||||
case '\u0028': return 0x28;
|
||||
case '\u0029': return 0x29;
|
||||
case '\u002A': return 0x2A;
|
||||
case '\u002B': return 0x2B;
|
||||
case '\u002C': return 0x2C;
|
||||
case '\u002D': return 0x2D;
|
||||
case '\u002E': return 0x2E;
|
||||
case '\u002F': return 0x2F;
|
||||
case '\u0030': return 0x30;
|
||||
case '\u0031': return 0x31;
|
||||
case '\u0032': return 0x32;
|
||||
case '\u0033': return 0x33;
|
||||
case '\u0034': return 0x34;
|
||||
case '\u0035': return 0x35;
|
||||
case '\u0036': return 0x36;
|
||||
case '\u0037': return 0x37;
|
||||
case '\u0038': return 0x38;
|
||||
case '\u0039': return 0x39;
|
||||
case '\u003A': return 0x3A;
|
||||
case '\u003B': return 0x3B;
|
||||
case '\u003C': return 0x3C;
|
||||
case '\u003D': return 0x3D;
|
||||
case '\u003E': return 0x3E;
|
||||
case '\u003F': return 0x3F;
|
||||
case '\u0040': return 0x40;
|
||||
case '\u0041': return 0x41;
|
||||
case '\u0042': return 0x42;
|
||||
case '\u0043': return 0x43;
|
||||
case '\u0044': return 0x44;
|
||||
case '\u0045': return 0x45;
|
||||
case '\u0046': return 0x46;
|
||||
case '\u0047': return 0x47;
|
||||
case '\u0048': return 0x48;
|
||||
case '\u0049': return 0x49;
|
||||
case '\u004A': return 0x4A;
|
||||
case '\u004B': return 0x4B;
|
||||
case '\u004C': return 0x4C;
|
||||
case '\u004D': return 0x4D;
|
||||
case '\u004E': return 0x4E;
|
||||
case '\u004F': return 0x4F;
|
||||
case '\u0050': return 0x50;
|
||||
case '\u0051': return 0x51;
|
||||
case '\u0052': return 0x52;
|
||||
case '\u0053': return 0x53;
|
||||
case '\u0054': return 0x54;
|
||||
case '\u0055': return 0x55;
|
||||
case '\u0056': return 0x56;
|
||||
case '\u0057': return 0x57;
|
||||
case '\u0058': return 0x58;
|
||||
case '\u0059': return 0x59;
|
||||
case '\u005A': return 0x5A;
|
||||
case '\u005B': return 0x5B;
|
||||
case '\u005C': return 0x5C;
|
||||
case '\u005D': return 0x5D;
|
||||
case '\u2191': return 0x5E;
|
||||
case '\u005F': return 0x5F;
|
||||
case '\u00A3': return 0x60;
|
||||
case '\u0061': return 0x61;
|
||||
case '\u0062': return 0x62;
|
||||
case '\u0063': return 0x63;
|
||||
case '\u0064': return 0x64;
|
||||
case '\u0065': return 0x65;
|
||||
case '\u0066': return 0x66;
|
||||
case '\u0067': return 0x67;
|
||||
case '\u0068': return 0x68;
|
||||
case '\u0069': return 0x69;
|
||||
case '\u006A': return 0x6A;
|
||||
case '\u006B': return 0x6B;
|
||||
case '\u006C': return 0x6C;
|
||||
case '\u006D': return 0x6D;
|
||||
case '\u006E': return 0x6E;
|
||||
case '\u006F': return 0x6F;
|
||||
case '\u0070': return 0x70;
|
||||
case '\u0071': return 0x71;
|
||||
case '\u0072': return 0x72;
|
||||
case '\u0073': return 0x73;
|
||||
case '\u0074': return 0x74;
|
||||
case '\u0075': return 0x75;
|
||||
case '\u0076': return 0x76;
|
||||
case '\u0077': return 0x77;
|
||||
case '\u0078': return 0x78;
|
||||
case '\u0079': return 0x79;
|
||||
case '\u007A': return 0x7A;
|
||||
case '\u007B': return 0x7B;
|
||||
case '\u007C': return 0x7C;
|
||||
case '\u007D': return 0x7D;
|
||||
case '\u007E': return 0x7E;
|
||||
case '\u00A9': return 0x7F;
|
||||
case '\u259D': return 0x81;
|
||||
case '\u2598': return 0x82;
|
||||
case '\u2580': return 0x83;
|
||||
case '\u2597': return 0x84;
|
||||
case '\u2590': return 0x85;
|
||||
case '\u259A': return 0x86;
|
||||
case '\u259C': return 0x87;
|
||||
case '\u2596': return 0x88;
|
||||
case '\u259E': return 0x89;
|
||||
case '\u258C': return 0x8A;
|
||||
case '\u259B': return 0x8B;
|
||||
case '\u2584': return 0x8C;
|
||||
case '\u259F': return 0x8D;
|
||||
case '\u2599': return 0x8E;
|
||||
case '\u2588': return 0x8F;
|
||||
default:
|
||||
// Fallback to '?'
|
||||
return 0x3F;
|
||||
}
|
||||
}
|
||||
'\u0009' => 0x06,
|
||||
'\u000D' => 0x0D,
|
||||
'\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,
|
||||
'\u2191' => 0x5E,
|
||||
'\u005F' => 0x5F,
|
||||
'\u00A3' => 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,
|
||||
'\u00A9' => 0x7F,
|
||||
'\u259D' => 0x81,
|
||||
'\u2598' => 0x82,
|
||||
'\u2580' => 0x83,
|
||||
'\u2597' => 0x84,
|
||||
'\u2590' => 0x85,
|
||||
'\u259A' => 0x86,
|
||||
'\u259C' => 0x87,
|
||||
'\u2596' => 0x88,
|
||||
'\u259E' => 0x89,
|
||||
'\u258C' => 0x8A,
|
||||
'\u259B' => 0x8B,
|
||||
'\u2584' => 0x8C,
|
||||
'\u259F' => 0x8D,
|
||||
'\u2599' => 0x8E,
|
||||
'\u2588' => 0x8F,
|
||||
_ => 0x3F
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
Library to provide codepage conversion to and from archaic and old computer systems and Unicode.
|
||||
|
||||
Copyright © 2016-2019 Natalia Portillo <claunia@claunia.com>
|
||||
Copyright © 2016-2021 Natalia Portillo <claunia@claunia.com>
|
||||
|
||||
Supported encodings
|
||||
==============================
|
||||
|
||||
Reference in New Issue
Block a user