-
Notifications
You must be signed in to change notification settings - Fork 189
Extend stdlib_ascii module for handling character variables #310
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6720abd
Extend stdlib_ascii module for handling character variables
awvwgk e47f028
Apply restructring of specs from review
awvwgk 591678d
Update documentation comments in stdlib_ascii
awvwgk c92f414
Fix link generation and code block issues with FORD
awvwgk 59b195e
Reword capitalization rules
awvwgk e670262
promote public functions to elemental
milancurcic 546fece
Revert e67026237c7cce2ea47cc2bcb6b68e94754782ee
awvwgk 6e9574b
Apply suggestions from code review
jvdp1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
--- | ||
title: ASCII | ||
--- | ||
|
||
# The `stdlib_ascii` module | ||
|
||
[TOC] | ||
|
||
## Introduction | ||
|
||
The `stdlib_ascii` module provides procedures for handling and manipulating | ||
intrinsic character variables and constants. | ||
|
||
|
||
## Constants provided by `stdlib_ascii` | ||
|
||
@note Specification of constants is currently incomplete. | ||
|
||
|
||
## Specification of the `stdlib_ascii` procedures | ||
|
||
@note Specification of procedures is currently incomplete. | ||
|
||
|
||
### `to_lower` | ||
|
||
#### Status | ||
|
||
Experimental | ||
|
||
#### Description | ||
|
||
Converts input character variable to all lowercase. | ||
|
||
#### Syntax | ||
|
||
`res = [[stdlib_asciii(module):to_lower(function)]] (string)` | ||
|
||
#### Class | ||
|
||
Pure function. | ||
|
||
#### Argument | ||
|
||
`string`: shall be an intrinsic character type. It is an `intent(in)` argument. | ||
|
||
#### Result value | ||
|
||
The result is an intrinsic character type of the same length as `string`. | ||
|
||
awvwgk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#### Example | ||
|
||
```fortran | ||
program demo_to_lower | ||
use stdlib_ascii, only : to_lower | ||
implicit none | ||
print'(a)', to_lower("HELLo!") ! returns "hello!" | ||
end program demo_to_lower | ||
``` | ||
|
||
### `to_upper` | ||
|
||
#### Status | ||
|
||
Experimental | ||
|
||
#### Description | ||
|
||
Converts input character variable to all uppercase. | ||
|
||
#### Syntax | ||
|
||
`res = [[stdlib_ascii(module):to_upper(function)]] (string)` | ||
|
||
#### Class | ||
|
||
Pure function. | ||
|
||
#### Argument | ||
|
||
`string`: shall be an intrinsic character type. It is an `intent(in)` argument. | ||
|
||
#### Result value | ||
|
||
The result is an intrinsic character type of the same length as `string`. | ||
|
||
awvwgk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#### Example | ||
|
||
```fortran | ||
program demo_to_upper | ||
use stdlib_ascii, only : to_upper | ||
implicit none | ||
print'(a)', to_upper("hello!") ! returns "HELLO!" | ||
end program demo_to_upper | ||
``` | ||
|
||
awvwgk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
### `to_title` | ||
|
||
#### Status | ||
|
||
Experimental | ||
|
||
#### Description | ||
|
||
Returns a capitalized version of an input character variable. | ||
The first alphabetical character is transformed to uppercase unless it follows a numeral. | ||
The rest of the character sequence is transformed to lowercase. | ||
|
||
#### Syntax | ||
|
||
`res = [[stdlib_ascii(module):to_title(interface)]] (string)` | ||
jvdp1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### Class | ||
|
||
Pure function. | ||
|
||
#### Argument | ||
|
||
`string`: shall be an intrinsic character type. It is an `intent(in)` argument. | ||
|
||
#### Result value | ||
|
||
The result is an intrinsic character type of the same length as `string`. | ||
|
||
awvwgk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#### Example | ||
|
||
```fortran | ||
program demo_to_title | ||
use stdlib_ascii, only : to_title | ||
implicit none | ||
print*, to_title("hello!") ! returns "Hello!" | ||
print*, to_title("'enquoted'") ! returns "'Enquoted'" | ||
print*, to_title("1st") ! returns "1st" | ||
end program demo_to_title | ||
``` | ||
|
||
### `reverse` | ||
|
||
#### Status | ||
|
||
Experimental | ||
|
||
#### Description | ||
|
||
Reverses the order of all characters in the input character type. | ||
|
||
#### Syntax | ||
|
||
`res = [[stdlib_ascii(module):reverse(function)]] (string)` | ||
|
||
#### Class | ||
|
||
Pure function. | ||
|
||
#### Argument | ||
|
||
`string`: shall be an intrinsic character type. It is an `intent(in)` argument. | ||
|
||
#### Result value | ||
|
||
The result is an intrinsic character type of the same length as `string`. | ||
awvwgk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### Example | ||
|
||
```fortran | ||
program demo_reverse | ||
use stdlib_ascii, only : reverse | ||
implicit none | ||
print'(a)', reverse("Hello, World!") ! returns "!dlroW ,olleH" | ||
end program demo_reverse | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.