How can developers effectively debug and test a custom word wrapping function in PHP, considering the potential complexities of Unicode characters and special cases like combining diacritical marks?

Developers can effectively debug and test a custom word wrapping function in PHP by using test cases that include a variety of Unicode characters and special cases like combining diacritical marks. They should also consider edge cases such as long strings with no spaces or strings containing only special characters. By thoroughly testing the function with different inputs, developers can ensure that it handles all scenarios correctly.

function customWordWrap($input, $length) {
    // Implement custom word wrapping logic here
}

// Test the custom word wrapping function with different inputs
$input1 = "Hello, world!";
$input2 = "Tésting combining diacritical marks: áéíóú";
$input3 = "Testing a long string with no spaces and special characters: !@#$%^&*()";
$length = 10;

echo customWordWrap($input1, $length) . "\n";
echo customWordWrap($input2, $length) . "\n";
echo customWordWrap($input3, $length) . "\n";