(#) Hyphen can be replaced with dash !!! WARNING: Hyphen can be replaced with dash This is a warning. Id : `TypographyDashes` Summary : Hyphen can be replaced with dash Severity : Warning Category : Usability: Typography Platform : Android Vendor : Android Open Source Project Feedback : https://issuetracker.google.com/issues/new?component=192708 Since : Initial Affects : Resource files Editing : This check runs on the fly in the IDE editor See : https://en.wikipedia.org/wiki/Dash Implementation : [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/TypographyDetector.kt) Tests : [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/TypographyDetectorTest.kt) Copyright Year : 2011 The "n dash" (\u2013, –) and the "m dash" (\u2014, —) characters are used for ranges (n dash) and breaks (m dash). Using these instead of plain hyphens can make text easier to read and your application will look more polished. !!! Tip This lint check has an associated quickfix available in the IDE. (##) Example Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/values/typography.xml:17:Warning: Replace "-" with an "en dash" character (–, –) ? [TypographyDashes] <string name="ndash">For ages 3-5</string> ------------ res/values/typography.xml:18:Warning: Replace "-" with an "en dash" character (–, –) ? [TypographyDashes] <string name="ndash2">Copyright 2007 - 2011</string> --------------------- res/values/typography.xml:20:Warning: Replace "--" with an "em dash" character (—, —) ? [TypographyDashes] <string name="mdash">Not found -- please try again</string> ----------------------------- res/values/typography.xml:24:Warning: Replace "-" with an "en dash" character (–, –) ? [TypographyDashes] <item>Ages 3-5</item> -------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: `res/values/typography.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers <resources> <string name="home_title">Home 'Sample'</string> <string name="show_all_apps">"All"</string> <string name="show_all_apps2">Show "All"</string> <string name="escaped">Skip \"All\"</string> <string name="single">Android's</string> <string name="copyright">(c) 2011</string> <string name="badquotes1">`First'</string> <string name="badquotes2">``second''</string> <string name="notbadquotes">Type Option-` then 'Escape'</string> <string name="fraction1">5 1/2 times</string> <string name="fraction4">1/4 times</string> <string name="notfraction">51/2 times, 1/20</string> <string name="ellipsis">40 times...</string> <string name="notellipsis">40 times.......</string> <string name="ndash">For ages 3-5</string> <string name="ndash2">Copyright 2007 - 2011</string> <string name="nontndash">x-y</string> <string name="mdash">Not found -- please try again</string> <string name="nontndash">----</string> <string name="notdirectional">A's and B's</string> <string-array name="typography"> <item>Ages 3-5</item> <item>Age 5 1/2</item> </string-array> <string name="ndash">X Y Z: 10 10 -1</string> <string name="ga_trackingId">UA-0000-0</string> <string>something somthing d\'avoir something something l\'écran.</string> </resources> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can also visit the [source code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/TypographyDetectorTest.kt) for the unit tests for this check to see additional scenarios. (##) Suppressing You can suppress false positives using one of the following mechanisms: * Adding the suppression attribute `tools:ignore="TypographyDashes"` on the problematic XML element (or one of its enclosing elements). You may also need to add the following namespace declaration on the root element in the XML file if it's not already there: `xmlns:tools="http://schemas.android.com/tools"`. ```xml <?xml version="1.0" encoding="UTF-8"?> <resources xmlns:tools="http://schemas.android.com/tools"> ... <string tools:ignore="TypographyDashes" .../> ... </resources> ``` * Using a special `lint.xml` file in the source tree which turns off the check in that folder and any sub folder. A simple file might look like this: ```xml <?xml version="1.0" encoding="UTF-8"?> <lint> <issue id="TypographyDashes" severity="ignore" /> </lint> ``` Instead of `ignore` you can also change the severity here, for example from `error` to `warning`. You can find additional documentation on how to filter issues by path, regular expression and so on [here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html). * In Gradle projects, using the DSL syntax to configure lint. For example, you can use something like ```gradle lintOptions { disable 'TypographyDashes' } ``` In Android projects this should be nested inside an `android { }` block. * For manual invocations of `lint`, using the `--ignore` flag: ``` $ lint --ignore TypographyDashes ...` ``` * Last, but not least, using baselines, as discussed [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).