Skip to content

Commit

Permalink
Change the function name
Browse files Browse the repository at this point in the history
  • Loading branch information
dokutoku committed Mar 8, 2021
1 parent bd3a3ea commit 427668e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ It is very simple to use.
```d
import wcwidth_compat;
assert(wcwidth_compat(cast(uint)('A') == 2);
assert(wcwidth(cast(uint)('A') == 2);
```

### wasm
Expand All @@ -33,7 +33,7 @@ let bytes = new Uint8Array(fs.readFileSync('./wcwidth-compat.wasm'));
let instance = new WebAssembly.Instance(new WebAssembly.Module(bytes), {});

let input = '';
console.log(instance.exports.wcwidth_compat(input.codePointAt(0)));
console.log(instance.exports.wcwidth(input.codePointAt(0)));
```

## Related project
Expand Down
2 changes: 1 addition & 1 deletion include/wcwidth-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
extern "C" {
#endif

int32_t wcwidth_compat(uint32_t ucs);
int32_t wcwidth(uint32_t ucs);

#ifdef __cplusplus
}
Expand Down
32 changes: 16 additions & 16 deletions source/wcwidth_compat/wcwidth.d
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ private bool intable(immutable ref .width_interval[] table, size_t table_length,
///
extern (C)
pure nothrow @safe @nogc @live
public int wcwidth_compat(uint ucs)
public int wcwidth(uint ucs)

out(result)
{
Expand Down Expand Up @@ -1423,25 +1423,25 @@ public int wcwidth_compat(uint ucs)

unittest
{
assert(.wcwidth_compat(cast(uint)('a')) == 1);
assert(.wcwidth_compat(cast(uint)('ö')) == 1);
assert(.wcwidth(cast(uint)('a')) == 1);
assert(.wcwidth(cast(uint)('ö')) == 1);

// Some wide:
assert(.wcwidth_compat(cast(uint)('')) == 2);
assert(.wcwidth_compat(cast(uint)('')) == 2);
assert(.wcwidth_compat(cast(uint)('')) == 2);
assert(.wcwidth_compat(cast(uint)('')) == 2);
assert(.wcwidth_compat(cast(uint)('')) == 2);
assert(.wcwidth_compat(cast(uint)(0x679C)) == 2);
assert(.wcwidth_compat(cast(uint)(0x679D)) == 2);
assert(.wcwidth_compat(cast(uint)(0x02070E)) == 2);
assert(.wcwidth_compat(cast(uint)(0x020731)) == 2);

assert(.wcwidth_compat(cast(uint)(0x11A3)) == 1);
assert(.wcwidth(cast(uint)('')) == 2);
assert(.wcwidth(cast(uint)('')) == 2);
assert(.wcwidth(cast(uint)('')) == 2);
assert(.wcwidth(cast(uint)('')) == 2);
assert(.wcwidth(cast(uint)('')) == 2);
assert(.wcwidth(cast(uint)(0x679C)) == 2);
assert(.wcwidth(cast(uint)(0x679D)) == 2);
assert(.wcwidth(cast(uint)(0x02070E)) == 2);
assert(.wcwidth(cast(uint)(0x020731)) == 2);

assert(.wcwidth(cast(uint)(0x11A3)) == 1);

// Koala emoji.
assert(.wcwidth_compat(cast(uint)(0x01F428)) == 2);
assert(.wcwidth(cast(uint)(0x01F428)) == 2);

// Watch emoji.
assert(.wcwidth_compat(cast(uint)(0x231A)) == 2);
assert(.wcwidth(cast(uint)(0x231A)) == 2);
}

0 comments on commit 427668e

Please sign in to comment.