README
1NAME
2
3 String::ToIdentifier::EN - Convert Strings to English Program
4 Identifiers
5
6SYNOPSIS
7
8 use utf8;
9 use String::ToIdentifier::EN 'to_identifier';
10
11 to_identifier 'foo-bar'; # fooDashBar
12 to_identifier 'foo-bar', '_'; # foo_dash_bar
13 to_identifier 'foo.bar', '_'; # foo_dot_bar
14 to_identifier "foo\x{4EB0}bar"; # fooJingBar
15 to_identifier "foo\x00bar"; # fooNullCharBar
16 to_identifier "foo\x00\x00bar"; # foo2NullCharsBar
17 to_identifier "foo\x00\x00bar", '_'; # foo_2_null_chars_bar
18
19 {
20 no utf8;
21 to_identifier "foo\xFF\xFFbar.baz"; # foo_2_0xFF_BarDotBaz
22 to_identifier "foo\xFF\xFFbar.baz", '_'; # foo_2_0xFF_bar_dot_baz
23 }
24
25DESCRIPTION
26
27 This module provides a utility method, "to_identifier" for converting
28 an arbitrary string into a readable representation using the ASCII
29 subset of \w for use as an identifier in a computer program. The intent
30 is to make unique identifier names from which the content of the
31 original string can be easily inferred by a human just by reading the
32 identifier.
33
34 If you need the full set of \w including Unicode, see the subclass
35 String::ToIdentifier::EN::Unicode.
36
37 Currently, this process is one way only, and will likely remain this
38 way.
39
40 The default is to create camelCase identifiers, or you may pass in a
41 separator char of your choice such as _.
42
43 Binary char groups will be separated by _ even in camelCase identifiers
44 to make them easier to read, e.g.: foo_2_0xFF_Bar.
45
46EXPORT
47
48 Optionally exports the "to_identifier" function.
49
50SUBROUTINES
51
52 to_identifier
53
54 Takes the string to be converted to an identifier, and optionally a
55 separator char such as _. If a separator char is not provided, a
56 camelCase identifier will be returned.
57
58METHODS
59
60 string_to_identifier
61
62 The class method version of "to_identifier", if you want to use the
63 object oriented interface.
64
65SEE ALSO
66
67 String::ToIdentifier::EN::Unicode, Text::Unidecode,
68 Lingua::EN::Inflect::Phrase
69
70AUTHOR
71
72 Rafael Kitover, <rkitover@gmail.com>
73
74REPOSITORY
75
76 http://github.com/rkitover/string-toidentifier-en
77
78LICENSE AND COPYRIGHT
79
80 Copyright (c) 2018 Rafael Kitover <rkitover@gmail.com>.
81
82 This program is free software; you can redistribute it and/or modify it
83 under the terms of either: the GNU General Public License as published
84 by the Free Software Foundation; or the Artistic License.
85
86 See http://dev.perl.org/licenses/ for more information.
87
88