Unicode bidirectional control character in source

ID

objectivec.correctness.misleading_bidirectional

Severity

low

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Suspicious Code

Language

Objective-C

Description

Reports a line containing a Unicode bidirectional formatting character - a left-to-right or right-to-left mark, embedding, override or isolate, or the Arabic letter mark. Ordinary non-Latin text, and zero-width characters that only affect glyph shaping, are not reported.

Rationale

These characters reorder the text an editor or a code-review page displays without changing a single token the compiler sees, so the code a reviewer reads can differ from the code that is compiled. A condition can be made to look inverted, a comment can appear to end early with live code hidden behind it, and a string constant can display a value it does not hold - all while the diff looks clean.

The following code illustrates the pattern detected by this rule:

@implementation AccessCheck
// FLAGGED: Unicode bidirectional control character in source
static NSString *const kBanner = @"admin‮ rekcah‬";
@end

Remediation

Delete the control characters. Where right-to-left text genuinely belongs in a string, move it into a localised resource file rather than a source literal, or write it with explicit \u escapes so the bytes are visible in review.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved