Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substitute parameter for Decode with UTF strings. #78

Closed
Blady-Com opened this issue Jan 14, 2024 · 6 comments
Closed

Substitute parameter for Decode with UTF strings. #78

Blady-Com opened this issue Jan 14, 2024 · 6 comments
Labels
ARG Concluded The ARG has formally presided over this issue. Feature Request A proposal for a new language feature or capability

Comments

@Blady-Com
Copy link

In Ada.Strings.UTF_Encoding.Strings the Decode function function Decode (Item: UTF_8_String) return String;
causes Encoding_Error exception if the string contains a character that is not representable in Latin 1.
My proposal is to add a version of Decode with a substitution character, for example:
function Decode (Item: UTF_8_String; Substitute: Character) return String;
or add a Substitute parameter with a default value:
function Decode (Item: UTF_8_String; Substitute: Character := ' ') return String;

A workaround is to use To_String and Decode for Wide_Wide_String, for exemple:
My_String : String := Ada.Characters.Conversions.To_String (Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Decode (My_UTF_String), '#');
A dedicated Decode function would be lighter and simpler by avoiding the need to go back and forth to the Wide_Wide_Strings.

Idem with other Decode forms:

function Decode (Item : UTF_String; Input_Scheme : Encoding_Scheme) return String;
function Decode (Item : UTF_8_String) return String;
function Decode (Item : UTF_16_Wide_String) return String;

And in Ada.Strings.UTF_Encoding.Wide_Wide_Strings:

function Decode (Item : UTF_String; Input_Scheme : Encoding_Scheme) return Wide_Wide_String;
function Decode (Item : UTF_8_String) return Wide_Wide_String;
function Decode (Item : UTF_16_Wide_String) return Wide_Wide_String;
@nholsti
Copy link

nholsti commented Feb 14, 2024

Adding a Substitute parameter with a default value to the Decode function is incompatible if it means that Decode no longer causes Encoding_Error. We could repair that by requiring that the default value of Substitute makes Decode work as before -- that is, cause Encoding_Error instead of using the Substitute -- but that would differ from how Substitute parameters work in Ada.Strings.UTF_Encoding, which could be quite confusing. But adding a version of Decode with a Substitute parameter with no default seems ok to me.

@joshua-c-fletcher
Copy link

joshua-c-fletcher commented Feb 14, 2024 via email

@ARG-Editor
Copy link
Collaborator

I think he meant the Substitute parameters in Ada.Characters.Conversions. Maybe not quite as close, but still uncomfortable to have operate differently.

@ARG-Editor ARG-Editor added the Feature Request A proposal for a new language feature or capability label Feb 15, 2024
@nholsti
Copy link

nholsti commented Feb 15, 2024

I think he meant the Substitute parameters in Ada.Characters.Conversions.

Yes, apologies for the mis-reference.

@ARG-Editor ARG-Editor added the ARG Agenda An AI has been created for the issue and it is on the ARG's agenda for resolution label Apr 19, 2024
@ARG-Editor ARG-Editor added ARG Concluded The ARG has formally presided over this issue. and removed ARG Agenda An AI has been created for the issue and it is on the ARG's agenda for resolution labels May 5, 2024
@ARG-Editor
Copy link
Collaborator

ARG-Editor commented May 5, 2024

AI22-0102-1 has been created for this issue.

@ARG-Editor
Copy link
Collaborator

ARG-Editor commented May 5, 2024

AI22-0102-1 was approved at ARG meeting #63D. This issue is completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ARG Concluded The ARG has formally presided over this issue. Feature Request A proposal for a new language feature or capability
Projects
None yet
Development

No branches or pull requests

4 participants